Differences between revisions 1 and 6 (spanning 5 versions)
Revision 1 as of 2005-03-23 03:48:00
Size: 643
Editor: h-67-100-157-227
Comment: Added tip from Thomas
Revision 6 as of 2024-06-30 17:21:02
Size: 291
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
ThomasHeller posted this tip to the mailing list:

`main_is_frozen()` returns `True` when running the exe, and `False` when
running from a script.

`get_main_dir()` returns the directory name of the script or the directory
name of the exe - this is also sometimes useful.

{{{
#!python

import imp, os, sys

def main_is_frozen():
   return (hasattr(sys, "frozen") or # new py2exe
           hasattr(sys, "importers") # old py2exe
           or imp.is_frozen("__main__")) # tools/freeze

def get_main_dir():
   if main_is_frozen():
       return os.path.dirname(sys.executable)
   return os.path.dirname(sys.argv[0])
}}}
I'm Sonya, and I live in Bogong. <<<BR>>
><<<BR>>
>
I'm interested in Educational Studies, Scrapbooking, and Spanish art. I like exploring and reading fantasy.<<<BR>>
><<<BR>>
>
<<<BR>>
><<<BR>>
>
Here is my homepage:: [[https://glycooptimizer.com|Glyco Optimizer Blood Support]]

I'm Sonya, and I live in Bogong. <
><
> I'm interested in Educational Studies, Scrapbooking, and Spanish art. I like exploring and reading fantasy.<
><
> <
><
> Here is my homepage:: Glyco Optimizer Blood Support

HowToDetermineIfRunningFromExe (last edited 2024-06-30 17:21:02 by JimmyRetzlaff)