A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2004-March/043282.html below:

[Python-Dev] unexpected reload() behavior

[Python-Dev] unexpected reload() behaviorSkip Montanaro skip at pobox.com
Fri Mar 19 10:03:55 EST 2004
In working on the doc change for <http://python.org/sf/919099> I came across
this statement:

    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.

(The bit about names of unchanged objects still pointing to the old objects
is incorrect.  I'll fix that.)

Not believing that old objects remained after the reload() I wrote a short
test:

    a = 5
    b = 7
    c = (1,2,3)

imported it, modified it to

    a = 9
    c = (1,2,3)

then reloaded it.  I was surprised to find that reloadtst.b did indeed still
exist:

    >>> import reloadtst
    >>> dir(reloadtst)
    >>> dir(reloadtst)
    ['__builtins__', '__doc__', '__file__', '__name__', 'a', 'b', 'c']
    >>> # edit reloadtst.py
    ...
    >>> reload(reloadtst)
    <module 'reloadtst' from 'reloadtst.py'>
    >>> dir(reloadtst)
    ['__builtins__', '__doc__', '__file__', '__name__', 'a', 'b', 'c']

It seems counterintuitive to me that reloadtst.b should still be defined.
Is that behavior intention or accidental?

Skip

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4