[Tutor] Adding method to class after class initialization
Fri, 17 Nov 2000 00:47:42 -0600
here a hard nut to crack:
Let's say I do the following:
>>> def add(self, x, y):
... return x+y
>>> class Test:
>>> t = Test()
>>> t.add = add
But if I now call 'a.add(3, 3)' I did not pass enough arguments, since self
is not passed automatically. How can I fix that? Is there something like
setattr just for a method?
Thanks for your help.
CBU - Physics and Chemistry Student
Web2k - Web Design/Development & Technical Project Management