[PythonCE] Running scripts by double clicking

Christian Baumgärtel chrbaumgaertel at gmx.de
Mon Jul 12 21:43:03 CEST 2004


> Hi Ryan,
>    >
> The problem with this idea is that you can't use the trick 
> of. If __name__ == '__main__':
To work around this problem, (and around two other problems: adding the
directory of the script to the path to allow imports, and to correctly
supply commandline args), I have changed xFile.py:

My xFile.py:

__name__ = '__main__'
import sys
import os.path
__myfile = sys.argv[1]
del sys.argv[0]

Hope this helps (so far, I haven't encountered problems with this hack),

Christian Baumgärtel

More information about the PythonCE mailing list