reloading modules

Skip Montanaro skip at pobox.com
Wed Dec 3 16:37:55 EST 2003


    John> Reload will reload the specified module, but will not recursively
    John> reload modules imported by the specified module, sorry.

Nor adjust references to objects in the reloaded module.

    % python
    Python 2.4a0 (#6, Dec  2 2003, 13:06:05) 
    [GCC 3.3 20030304 (Apple Computer, Inc. build 1493)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import foo
    >>> from foo import a
    >>> foo.a, a
    (42, 42)
    >>> 
    [1]+  Stopped                 python
    montanaro:tmp% cat > foo.py
    a = 99
    montanaro:tmp% fg
    python
    reload(foo)
    <module 'foo' from 'foo.py'>
    >>> foo.a, a
    (99, 42)

Skip





More information about the Python-list mailing list