Deprecating reload() ???
dmq at gain.com
Fri Mar 12 20:54:15 CET 2004
On Fri, 12 Mar 2004 11:42:06 -0600, Skip Montanaro <skip at pobox.com>
> David> It's worse than just a surprise. It's a serious problem when
> David> what you need to do is what most people are expecting -- replace
> David> every reference to objects in the old module with references to
> David> the new objects. The problem becomes a near impossibility when
> David> those references are scattered throughout a multi-module program.
> This is where I think your model of how Python works has broken down.
> Objects don't live within modules. References to objects do. All objects
> inhabit a space not directly associated with any particular Python
> namespace. If I execute
> import urllib
> quote = urllib.quote
>quote and urllib.quote refer to different objects and compare False. (I
>suppose the cmp() routine for functions could compare code objects and other
[ snip ]
Understood. When I said "objects in the old module", I should have
said "objects from the old module". I wasn't making any assumption
about where these objects reside once loaded. I'm still assuming it
is possible ( even if difficult ) to locate and change all current
references to these objects. This may require a special "debug" mode
to keep track of this information.
Another "brute force" kind of solution would be to replace the old
objects with links to the new. Every refence, no matter where it came
from, would be re-routed. The inefficiency would only last until you
restart the program.
More information about the Python-list