making run time changes..
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Thu Sep 27 18:33:20 EDT 2007
En Thu, 27 Sep 2007 13:52:39 -0300, Piyush Jain <piyushj at cse.iitk.ac.in>
escribi�:
>> I am new(almost) to python. I wish to making a server in which I can
>> make changes at run time. For example , add a method to a
>> class/attribute to object etc. by sending it messages.
To add a new attribute with a name known only at runtime, use setattr
<http://docs.python.org/lib/built-in-funcs.html> either on the class (will
be a class attribute then) or any individual instance.
To create a new method, just assign a function to the class.
I'd suggest first learning a bit more about Python until you are more
fluent with the language. (And consider the risk of executing untrusted
code from the outside).
--
Gabriel Genellina
More information about the Python-list
mailing list