⇤ ← Revision 1 as of 2005-03-23 03:48:00
Size: 643
Comment: Added tip from Thomas
|
Size: 643
Comment: converted to 1.6 markup
|
No differences found! |
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.
1 import imp, os, sys
2
3 def main_is_frozen():
4 return (hasattr(sys, "frozen") or # new py2exe
5 hasattr(sys, "importers") # old py2exe
6 or imp.is_frozen("__main__")) # tools/freeze
7
8 def get_main_dir():
9 if main_is_frozen():
10 return os.path.dirname(sys.executable)
11 return os.path.dirname(sys.argv[0])