Chaning instance methods

Darrell news at dorb.com
Tue Apr 6 22:09:29 EDT 1999


Hope this helps.

>>> class X:
...     def y(self):
...             print 'y1'
...
>>> x=X()
>>> x.y()
y1
>>> def y2(self=x):
...     print 'y2'
...
>>> setattr(x,'y',y2)
>>> x.y()
y2
>>>






More information about the Python-list mailing list