Executing a modified function

Skip Montanaro skip at pobox.com
Thu Jan 2 16:21:11 EST 2003


    Dave> Is there a way to force the new version [of my function] to be
    Dave> executed in this situation, without leaving python and starting
    Dave> again?

In most instances, yes.  If you defined a function named "say_hello" in a
module named "talking_heads", you could edit talking_heads.py to modify
say_hello(), then execute

    reload(talking_heads)

to gain access to the new version of say_hello().

If you originally got to say_hello() via something like

    from talking_heads import say_hello

getting at an updated version of say_hello is a bit more complex:

    import talking_heads         # to get an object to pass to reload()
    reload(talking_heads)
    from talking_heads import say_hello

Skip





More information about the Python-list mailing list