from module import * using __import__?

Dan Stromberg drsalists at
Sat Jul 2 21:52:11 CEST 2011

Is there a decent way of running "from <variable> import *"?  Perhaps using

Does it mean using the copy module or adding an element to globals()

Yes, I think I do have a good use for this: importing either pure python or
cython versions of a module into a single namespace that can provide the
same interface (transparent to the caller), whether C extension modules are
viable in the current interpreter or not.  So you have a stub module that
provides one or the other, depending on availability and suitability.

Related bit: I want it to pylint smoothly despite being in a python package,
so I'd like to use normal import for the pure python, and __import__ (or
similar) for the cython - where the pure python and cython are automatically
generated from the same .m4 file, and the cython is attempted first, falling
back on the pure python if there's an ImportError.  I'd like to believe
pylint is going to check the pure python this way, and ignore the fact that
it often cannot import the cython.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list