Deprecating reload() ???
Mel Wilson
mwilson at the-wire.com
Fri Mar 12 10:29:18 EST 2004
In article <2j12505t4oaniqq7607t3pekulm0e979cu at 4ax.com>,
David MacQuigg <dmq at gain.com> wrote:
>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.
I don't quite get this. I don't see objects _in_ a
module. I see objects referenced from the modules
namespace, but they can be referenced from other modules'
namespaces at the same time. Who is to say which module the
objects are *in*?
e.g. (untested)
#===============================
"M1.py"
f1 = file ('a')
f2 = file ('b')
#===============================
"main.py"
import M1
a_file = M1.f1
another = file ('c')
M1.f2 = another
reload (M1)
Regards. Mel.
More information about the Python-list
mailing list