Deprecating reload() ???

David MacQuigg dmq at gain.com
Thu Mar 11 19:45:43 EST 2004


On Thu, 11 Mar 2004 15:10:59 -0500, "Ellinghaus, Lance"
<lance.ellinghaus at eds.com> wrote:

>> > Other surprises:  Deprecating reload()
>
>>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()? 

Seems like reload() could be *made* to work by scanning currently
loaded modules for all references to objects in the reloaded module,
and resetting them to the new objects.  If an object is missing from
the new module, throw an exception.

GvR suggests using 'exec' as an alternative.
http://python.org/doc/essays/ppt/regrets/6
I don't see how that solves the problem of eliminating references to
old objects.

-- Dave




More information about the Python-list mailing list