Self modifying systems question

Fernando Perez fperez528 at yahoo.com
Wed Apr 30 18:28:46 EDT 2003


Sten Kvamme wrote:

> Hello,
> 
> Self modifying code is a well known technology. Has anyone done this in
> Python? What I'm seeking for is examples of software that adds to
> itself (methods and variables) in runtime. I'd like an instantiated
> object to
> be able to add a method to itself.

I've attached a fairly non-trivial example below.  This is a function which
creates functions on the fly, and adds it to a currently running instance
of a python interpreter for shell access.  It's part of ipython
(http://ipython.scipy.org), in case you want to see how it works in 'real
life'.  The code snippet below is just a piece of a much larger code, so it
won't run by itself.  It's meant to illustrate the kinds of things you can
do.

Best,

f.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: alias.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20030430/a197c45f/attachment.ksh>


More information about the Python-list mailing list