[Python-Dev] Inconsistent behaviour in import/zipimport hooks

Nick Coghlan ncoghlan at gmail.com
Wed Nov 9 22:58:44 CET 2005

Bob Ippolito wrote:
> On Nov 9, 2005, at 1:22 PM, Bill Janssen wrote:
>> It's a shame that
>> 1)  there's no equivalent of "java -jar", i.e., "python -z  
>> FILE.ZIP", and
> This should work on a few platforms:
> env PYTHONPATH=FILE.zip python -m some_module_in_the_zip

Really? I wrote the '-m' code, and I wouldn't expect that to work anywhere 
because 'execfile' and the C equivalent that -m relies on expect a real file.

PEP 328 goes some way towards fixing that by having a Python fallback to find
and execute the module if the current C code fails. If we had execmodule as a
Python function, it would make it much easier to add support for
compiling and executing the target module directly, rather than indirecting
through the file-system-dependent execfile. In theory this could be done in C, 
but execmodule is fairly long even written in Python. I'm actually fairly sure 
it *could* be written in C, but I think doing so would be horribly tedious 
(and not as useful in the long run).


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list