Introspect imports from module

Christian Heimes lists at cheimes.de
Thu Jun 21 07:00:36 EDT 2012


Am 21.06.2012 10:03, schrieb Bastian Ballmann:
> Any suggestions how I could just get the import of module.to.inspect?
> Thanks && have a nice day!

You could try a completely different approach and use the compiler
package to inspect the abstract syntrax tree of a compiled module. The
approach has the nice side effect that you don't have to import a module
to inspect its imports. This script may serve as an example for you:

http://svn.zope.org/Zope3/trunk/utilities/importchecker.py?rev=113742&view=auto

Christian




More information about the Python-list mailing list