[Python-Dev] __import__ problems

Nick Coghlan ncoghlan at gmail.com
Fri Nov 28 23:25:26 CET 2008

Mart Somermaa wrote:
> But I'm still +1 for adding 'tail'/'submodule'/'tailmodule'
> argument to __import__ instead of providing an almost identical
> copy in imp.import_module().
> Let me know which of the approaches is desired (if any) and I'll
> add tests and update docs.

Have you considered using runpy.run_module() instead? i.e. do you
actually need the resulting module object, or just the global namespace
produced by running its code?

If the latter, then run_module() is a much better way of going about it
as it has (slightly) fewer side effects on the import system's internals.


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

More information about the Python-Dev mailing list