Finding Script Directory
peter at engcorp.com
Wed Jul 7 18:21:32 CEST 2004
Thomas Heller wrote:
> The 'sys.frozen' attribute should be used to determine if the
> script runs from py2exe or from a Python module.
Okay, so here's my first attempt (without checking whether there
is already one in the Cookbook or somewhere) at 'the' canonical
way to find the directory in which the main script or .exe (for frozen
apps) is found. Note that this uses sys.frozen and therefore
works for frozen apps only if they follow the py2exe mechanism.
(Do any of the others?)
path = sys.argv
path = sys.executable
Comments? Anyone have a better name?
More information about the Python-list