Re: Dynamically removing methods in new-style classes

2007-09-12 Thread Steven D'Aprano
On Wed, 12 Sep 2007 14:28:15 +, agupta0318 wrote: > I am trying unsuccessfully to remove some methods from an instance, > based on values passed in to the constructor as in the following > example: [snip] >>> class C(object): ... def method(self): ... return "method exists"

Re: Dynamically removing methods in new-style classes

2007-09-12 Thread Michele Simionato
On Sep 12, 4:28 pm, [EMAIL PROTECTED] wrote: > I am trying unsuccessfully to remove some methods from an instance, Usuall one does not remove methods, but wraps the object and delegates only to a restricted number of methods. Is this solution viable? If not, you may be forced to change the class o

Re: Dynamically removing methods in new-style classes

2007-09-12 Thread Hrvoje Niksic
[EMAIL PROTECTED] 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 desire

Dynamically removing methods in new-style classes

2007-09-12 Thread agupta0318
I am trying unsuccessfully to remove some methods from an instance, based on values passed in to the constructor as in the following example: #=== class A(object): def __init__(self, id): self._id = id