Differences between revisions 2 and 5 (spanning 3 versions)
Revision 2 as of 2008-07-08 11:27:43
Size: 643
Editor: localhost
Comment: converted to 1.6 markup
Revision 5 as of 2024-06-30 17:16:19
Size: 360
Editor: BarkXbuddy
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])
}}}
Nothing to write about myself I think.<<<BR>>
><<<BR>>
>
Yes! Im a member of py2exe.org.<<<BR>>
><<<BR>>
>
I really hope I'm useful at all<<<BR>>
><<<BR>>
>
<<<BR>>
><<<BR>>
>
My blog :: [[https://gita.jobrove.com/barkxbuddydogtrainers/barkxbuddy-dog-trainer2022/wiki/BarkXBuddy:-Finding-the-Right-Training-Frequency-for-Your-Dog|BarkXbuddy Dog]]

Nothing to write about myself I think.<
><
> Yes! Im a member of py2exe.org.<
><
> I really hope I'm useful at all<
><
> <
><
> My blog :: BarkXbuddy Dog

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