At 09:55 AM 7/23/2007 -0700, Guido van Rossum wrote:
On 7/12/07, Daniel Stutzbach firstname.lastname@example.org wrote:
On 7/11/07, Andy C email@example.com wrote:
The good thing about this is that it's extremely simple -- basically 20 lines of C code to add a -z flag that calls a 3-line Python function in the runpy module.
Instead of requiring a -z flag, why not have the interpreter peak at the file to see if it starts with one of the ZIP magic numbers?
That way it Just Works.
I guess you wouldn't recognize a zip file if it hits you in the face. Literally. :-)
Zip files don't start with a magic number.
I've actually started on a patch that uses the standard import hooks to figure out how to import __main__ from sys.argv, if it's something that an import hook can be found for (otherwise, it falls back to normal behavior).
At this point, the problem is that __main__ is a builtin module and already exists when this processing is being done, so trying to reload it in a straightforward way doesn't work. (Nor does using the standard -m logic.)
If I can figure out how to work around that bit, we won't need a -z flag, which means a #! line for zipfiles is possible on 'nix, and we can support arbitrary import hooks for sys.argv. (Assuming they're either built-in or registered via sitecustomize, that is.)