Running a Python script directly or from an exe?

home | blog | Teh Internet | guest blog |rants | placeholder | political | projects | Gwen and Liam | Citadel patched | Tools | Scouts


- Careful Chrome users, this search box might be "Not secure"


How can you get the runtime path if you can be run 2 ways?

http://stackoverflow.com/questions/404744/determining-application-path-in-a-python-exe-generated-by-pyinstaller

import os
import sys

config_name = 'myapp.cfg'

# determine if application is a script file or frozen exe
if hasattr(sys, 'frozen'):
    application_path = os.path.dirname(sys.executable)
elif __file__:
    application_path = os.path.dirname(__file__)

config_path = os.path.join(application_path, config_name)



[æ]