zipimport to read from a file object instead of just a path?
In zipimport.c, function get_data(), the zip file is opened using fopen() and read with CLib functions. Did anyone ever consider making it possible to read the zipped data from a generic file object and not just using a string path? Using StringIO, This would allow a higher degree of python embedding in an application. I would be able to have a zip file in memory and make python read modules from it.
Zitat von Shy Shalom
In zipimport.c, function get_data(), the zip file is opened using fopen() and read with CLib functions. Did anyone ever consider making it possible to read the zipped data from a generic file object and not just using a string path?
It's already possible - just write another importer. For the builtin zipimport, this is not an option, since it seeds itself from the sys.path entry, which will be a file name. See PEP 302. Regards, Martin
It's already possible - just write another importer. For the builtin zipimport, this is not an option, since it seeds itself from the sys.path entry, which will be a file name. See PEP 302.
Regards, Martin
Maybe it can be seeded by both a string path *or* a file object, the same way zipfile.ZipFile does. This way I'll be able to somehow override or re-initialize zipimport with my own StringIO - Shy
participants (2)
-
martin@v.loewis.de
-
Shy Shalom