Deprecating reload() ???

David MacQuigg dmq at gain.com
Wed Mar 17 13:26:07 EST 2004


On Thu, 11 Mar 2004 15:10:59 -0500, "Ellinghaus, Lance"
<lance.ellinghaus at eds.com> wrote:
>
>>Reload doesn't work the way most people think
>>it does: if you've got any references to the old module,
>>they stay around. They aren't replaced.
>
>>It was a good idea, but the implementation simply
>>doesn't do what the idea promises.
>
>I agree that it does not really work as most people think it does, but how
>would you perform the same task as reload() without the reload()? 

>>> pzfuncs
<open file 'PZfuncs.py', mode 'r' at 0x00A86160>
>>> exec pzfuncs
>>> p3
-2

--- Edit PZfuncs.py here ---

>>> pzfuncs.seek(0)
>>> exec pzfuncs
>>> p3
-3
>>> 

The disadvantage compared to reload() is that you get direct
references to *all* the new objects in your current namespace.  With
reload() you get only a reference to the reloaded module.  With the
proposed super_reload (at least the version I would like) you get no
new references in your current namespace, just updates on the
references that are already there.

Hmm.  Maybe we could reload(), then loop over the available names, and
replace any that exist in the current namespace.

-- Dave




More information about the Python-list mailing list