How to 'from package import module; from module import variable'?

Oleg Broytmann phd at phd.fep.ru
Mon Jul 9 09:49:04 EDT 2001


On 9 Jul 2001, Alex wrote:
> Hi.  I've recently switched to using packages.  Because I use reload a
> lot during testing, it'd be helpful to be able to do this sort of thing
> successfully:
>
> >>> from mouse.tools import queues
> >>> from queues import Cyclic_queue
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> ImportError: No module named queues
>
> My understanding of the package import routine is still sort of sketchy,
> but I was wondering if there's a way to convince the import function
> that queues is actually a module it can import from.

from mouse.tools import queues

import sys
sys.modules["queues"] = queues

from queues import Cyclic_queue

Oleg.
----
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list