Dynamically removing methods in new-style classes
Hrvoje Niksic
hniksic at xemacs.org
Wed Sep 12 10:41:08 EDT 2007
More information about the Python-list mailing list
Wed Sep 12 10:41:08 EDT 2007
- Previous message (by thread): Dynamically removing methods in new-style classes
- Next message (by thread): Dynamically removing methods in new-style classes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
agupta0318 at gmail.com writes: > I am trying unsuccessfully to remove some methods from an instance, You can't remove the method from an instance because the method is stored in its class. > With the older python classes I could have done: > self.__class__.__dict__[''test1"] to achieve the desired result. self.__class__.test1 still works, doesn't it? Removing methods can be achieved the same way: >>> x=X() >>> class X(object): ... def blah(self): pass ... >>> x=X() >>> x.blah <bound method X.blah of <__main__.X object at 0xb7d46bcc>> >>> del type(x).blah >>> x.blah Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'X' object has no attribute 'blah'
- Previous message (by thread): Dynamically removing methods in new-style classes
- Next message (by thread): Dynamically removing methods in new-style classes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list