Duplicating Modules

Peter Otten __peter__ at web.de
Fri Sep 30 14:32:28 EDT 2005


kimes wrote:

> Why don't you do like this..
> 
> import module
> import mudule as module2

>>> import module as a
>>> import module as b
>>> b is a
True

You have to remove the module from the cache before the second import:

>>> import sys
>>> import module as a
>>> del sys.modules["module"]
>>> import module as b
>>> b is a
False

Peter





More information about the Python-list mailing list