[Tutor] Adding method to class after class initialization
Stephan Richter
srichter@cbu.edu
Fri, 17 Nov 2000 00:47:42 -0600
Hello everyone,
here a hard nut to crack:
Let's say I do the following:
>>> def add(self, x, y):
... return x+y
>>> class Test:
... pass
>>> 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.
Regards,
Stephan
--
Stephan Richter
CBU - Physics and Chemistry Student
Web2k - Web Design/Development & Technical Project Management