[Python-ideas] Enhance reload

Jim Jewett jimjjewett at gmail.com
Sun Sep 30 18:46:38 CEST 2007


On 9/29/07, Joseph Maurer <clarkksv at yahoo.com> wrote:
> I'd like to see the reload feature of Python enhanced so
> it can replace the methods for existing class instances,
> references to methods, and references to functions.

Guido did some work on this (as xreload) for Py3K, but gave up for the moment.

In the meantime, you can sometimes get a bit closer with indirection.
Instead of

    from othermod import anobject  # won't notice if anobject is replaced later

use

    import othermod
    ...
    othermod.anobject    # always looks up the current anobject

That said, subclasses and existing instances generally don't use
indirection, because it is slower; replacing bound methods will almost
certainly always require at least the moral equivalanent of reloading
the dialog after reloading the module.

-jJ



More information about the Python-ideas mailing list