[Python-Dev] Should there be a way or API for retrieving from a code object a loader method and package file where the code comes from?

Paul Moore p.f.moore at gmail.com
Tue Dec 23 15:06:31 CET 2008


2008/12/23 Rocky Bernstein <rocky at gnu.org>:
> Now that there is a package mechanism (are package mechanisms?) like
> zipimporter that bundle source code into a single file, should the
> notion of a "file" location should be adjusted to include the package
> and/or importer?

Check PEP 302 (http://www.python.org/dev/peps/pep-0302/) specifically
the get_source (optional) method. It's not exactly what you describe,
but it may help. Please note that it's optional - if you loaded the
code from a zipfile containing only bytecode files, there is no source
to get, so you have to be prepared for that case. But if the source is
available, this should give you a way of getting to it.

Paul.


More information about the Python-Dev mailing list