Reloading nested modules
Martin v. Löwis
martin at v.loewis.de
Mon Jul 14 22:21:12 CEST 2003
Greg Fortune <lists at gregfortune.com> writes:
> I've wondered about the same problem and considered that as a solution, but
> never tested it. I assume that *wouldn't* rebind all of the imports that
> have already happened.. ie, I think the references to the old copies of
> the modules would hang around even though new ones have been imported.
Depends on the import. For
the reload would take effect, as, on reload, the module object stays,
its dictionary stays, and it is just the dictionary contents that is
from foo import bar
you still have the old value of bar after reloading.
> Regardless, the scoping doesn't work so an attempt to reload the embedded
> module assumes it is available in local scope and fails. Again, that would
> lead me to believe my first statement is true, but when I tested just now,
> I got no further than the scoping problem...
What scoping problem?
> I've been intended to write something that will take a module name and
> rebind it in all namespaces that have it currently, but haven't got around
> to it. If I ever do, I'll post it here :)
Just ask Guido to borrow you the time machine - this has already been
More information about the Python-list