Deprecating reload() ???

David MacQuigg dmq at gain.com
Thu Mar 18 20:07:16 EST 2004


On Mon, 15 Mar 2004 13:50:47 -0600, Skip Montanaro <skip at pobox.com>
wrote:

>Please file a bug report on Sourceforge so your ideas don't get lost.  Feel
>free to assign it to me (sf id == "montanaro").

Done. SF bug ID is 919099.  Here is the proposed addition to
reload(module), just after the first paragraph:

"""
When reload(module) is executed:

The objects defined in module are compiled and loaded into memory as
new objects.

The old objects remain in memory until all references to them are
gone, and they are removed by the normal garbage-collection process.

The names in the module namespace are updated to point to any new or
changed objects.  Names of unchanged objects, or of objects no longer
present in the new module, remain pointing at the old objects.

Names in other modules that refer directly to the old objects (without
the module-name qualifier) remain unchanged and must be updated in
each namespace where they occur.
"""

Anyone with corrections or clarifications, speak now.

Also here is a bit that I'm not sure of from my write-up on reload()
at http://ece.arizona.edu/~edatools/Python/Reload.htm:

Footnotes
[1]  Reload(M1) is equivalent to the following:
>>> file = open(M1.__file__.rstrip('c'), 'r')
>>> file.seek(0)  # needed if this is not the first reload
>>> exec file in M1.__dict__  # repeat from line 2
>>> file.close()

-- Dave




More information about the Python-list mailing list