[Tutor] Modifying Source Code while Program is Running

Ed Singleton singletoned at gmail.com
Thu Nov 24 13:02:44 CET 2005


Is it feasible to change a program's source code whilst it is running
without having to restart the program?  Is it feasible to get a
program to change it's own source code while it is running?

For example, if you have a web server such as CherryPy that will
(hopefully) be running for months at a time and you want to be able to
change classes without having to restart the server.  Or if you want
to allow users of the site to edit a class through the web and see the
changes to the site immediately?

Can a python program change a class, change all the objects already
created by that class and save the modified class definition, so that
if the program were restarted it would return to exactly the same
state? (assuming all objects were saved to a database or somesuch).

Does anyone have any good links to implementations of this?  I assume
someone's already done it before.

Thanks

Ed


More information about the Tutor mailing list