[Numpy-discussion] Controlling the way a module is imported

Robert Kern robert.kern@gmail....
Sun May 25 04:57:25 CDT 2008


On Sun, May 25, 2008 at 4:28 AM, David Cournapeau
<david@ar.media.kyoto-u.ac.jp> wrote:
> Hi,
>
>    This is not numpy specific, but I need it for numpy/scipy. More
> specifically, I would like to be able to have one module interface which
> load imp1, imp2, imp3, etc... depending on some options.

Can you be more specific?

> I see two
> obvious solutions: monkey patching, and file configuration, but I try to
> avoid the former, and there is no mechanism for the later in scipy. I
> read that import hooks could be used for this purpose, but I don't quite
> understand the pep:
>
> http://www.python.org/dev/peps/pep-0302/
>
> Has anyone played with it ?

Avoid custom import hooks at all costs. They are very fragile and
interfere with each other.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco


More information about the Numpy-discussion mailing list