wasm-demo/demo/ermis-f/python_m/cur/0800

30 lines
466 B
Plaintext

From: news at dorb.com (Darrell)
Date: Tue, 6 Apr 1999 22:09:29 -0400
Subject: Chaning instance methods
References: <tx3soadh4jj.fsf@hog.ldgo.columbia.edu>
Message-ID: <m0zO2.1238$YU1.2534@newsr2.twcny.rr.com>
X-UID: 800
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
>>>