Adding methods to instances

Dody Suria Wijaya dodysw at
Fri Dec 16 17:40:29 CET 2005

To avoid that:
- subclass Test first

class SubclassTest(T):

- assign the method to SubclassTest's attribute,

SubclassTest.dynamic = dynamic

- then assign the new class to magic variable __class__ :

t.__class__ = SubclassTest


Antoon Pardon wrote:
> But this will make the function a method to all instances of the class.
> Is that what you want? From your first post I had the impression you
> only wanted the function to be the method of one particular instance.

More information about the Python-list mailing list