On Jan 6, 7:03 am, TechieInsights <gdoerm...@gmail.com> wrote: > __file__ command does not work when compiled to exe. It makes since > because the file is now in a compressed library. Is there a > replacement or something else you can do? The real problem is that > when you create an exe of your program with python embedded, you can't > always guarantee that your current directory is the directory of your > program.
How can you *ever* guarantee that the current directory is the same as the directory in which the program resides? This lack of guarantee is quite independent of whether the "program" is .py, .exe, .bat, .com, etc. Isn't the real problem how to find out which directory the program is in? > I guess when you could just set a registry entry on > windows... but it would be nice to have a quick fix for this (like > os.path.dirname(__file__)). if hasattr(sys, 'frozen'): answer = os.path.split(sys.executable)[0] else: answer = os.path.split(sys.argv[0])[0] (maybe) ... your question is a little unclear. HTH, John -- http://mail.python.org/mailman/listinfo/python-list