Changes during run

Mike 'Cat' Perkonigg blablu at
Mon May 29 14:48:47 CEST 2000

thiele at (Thomas Thiele) wrote in <393259F7.8AEE8518 at muc.das->:

>I have a program in which a function is called. For instance by pressing
>on a button (Tkinter).
>in mainframe class:
>def ButtonPressed(self):
>     self.Function()
>def Function(Self):
>     a = 5
>     print a
>I start the program and all things work great. Only the function
>Function is wrong (I wrote a = 5 instead of a = 6 ).
>Is it possible to correct the function without restarting the program?
>I start the program and press the button. I see a is 5. 
>I correct the source code (replace 5 with 6) and press the button again.
>And now I want to see that 6 is printed. 
>Is this possible? That would be really rapid prototyping!

It is.
You have to put your function in a seperate module and reload the module to 
update the function.
I have written a module which checks the file modification date of defined 
modules and reloads them if the files have been modified.
Works, but not if you make an instance of a class in such a module because 
the instance has a reference to the old class and the reload just creates a 
new class definition at another place.


More information about the Python-list mailing list