[Python-Dev] Add a -z interpreter flag to execute a zip file
Jim Jewett
jimjjewett at gmail.com
Fri Jul 13 19:09:01 CEST 2007
Andy C wrote:
>... a .zip file with a __zipmain__.py module at its root?
Why not just an __init__.py, which you would normally execute if you
tried to import/run a directory?
> * Magically looking at the first argument to see if it's a zip file
> seems problematic to me. I'd rather be explicit with the -z flag.
> Likewise, I'd rather be explicit and call it __zipmain__ rather than
> __main__.
Treating zip files (and only zip files) as a special case equivalent
to uncompressed files seems like a wart; I would prefer not to
special-case zips any more than they already are.
If anything, I would like to see the -m option enhanced so that if it
gets a recognized "collection" file type (including a directory or
zip), it does the right thing. Whether that actually makes sense, or
defeats the purpose of the -m shortcut, I'm not sure.
[on using __main__ instead of __init__ or __zipmain__]
> __main__.py? : ) If someone tries does import __main__ from another
> module in the program, won't that result in an infinite loop?
It doesn't today; it does use circular imports, which can be a problem.
> while I think it would be a bad practice to
> import __main__,
I have seen it recommended as the right place to store global
(cross-module) settings.
-jJ
More information about the Python-Dev
mailing list