Thanks for the answers, very helpful. I think I'm going to give Peter's hack a try, as it's actually quite close to what I'm trying to do -- I get the source for the new function, then that lets me make the old function become the new one. But I'll probably also use Michael's solution for class editing.
Now I just have to figure out how to take in-memory structures and turn them into Python source code. Hmm... that actually leads me back to Michael's solution more, since in that model you are always dealing with source, and if you faithfully reproduce the source then you should more-or-less reproduce the same structures. Hmm... challenging. I guess this is one motivation for languages like Smalltalk to use an image, because they don't have to serialize code as source. Of course, I could use one of those pickle alternatives that knows how to pickle live objects; but that takes the project much further from normal Python. -- http://mail.python.org/mailman/listinfo/python-list