Re: [cx-freeze-users] Whare are the functions / attributes that are unavailable to frozen apps?
Brought to you by:
atuining
From: Thomas K. <ta...@gm...> - 2013-02-17 18:25:44
|
On 17 February 2013 05:47, Mike Stoler <re...@ya...> wrote: > I gather that '__file__' is unavailable to frozen apps, > though I'm not sure why. > When you load Python code from a file, __file__ is the location of it on disk. That works for modules you import as well. But in a frozen application, the Python code isn't loaded from a file (in fact it's inside a zip archive), so __file__ doesn't really make sense. > Now, it seems that my frozen app > can't call the built-in 'exit()'. > As Michael has pointed out, exit() isn't really a built-in. It's a convenience function for using Python interactively, but in regular programs, you should use sys.exit(). There are a few interactive conveniences like exit() - quit(), copyright, license, credits - that you should avoid using in programs. Besides those, I think __file__ is the only thing that's not available. You may also need to be cautious about using sys.executable - normally it's the Python interpreter you're running in, so you can call it to start a subprocess with the same version of Python. In a frozen application, it will be the executable that launches your application. Thomas |