Why instancemethod when I can add functions to classes outside class body?
rimbalaya at yahoo.com
Fri Jul 25 06:27:38 CEST 2003
It appears to me the simplest way to add a function to a class outside
of the class declaration is as follows:
>>> class a(object):
>>> def f(self):
... print 'hi'
>>> a.f = f
It works even when the class and the function are in defined in
and the call to the method in a third module.
So what problem is the new.instancemethod() trying to solve?
It is ok to point me to a PEP or the like.
More information about the Python-list