Please reply inline; top posting is harder to read.
On Fri, Mar 12, 2010 at 12:15 AM, Gabriel Genellina
wrote:
En Thu, 11 Mar 2010 01:47:30 -0300, Radhakrishna Bhat
escribió:
I am using getattr to get a method instance from a class. But it also
returns methods from the superclass. How to de
thanks. It is working for simple classes. But now i am trying for complex
objects.
myclassinstance.__class__.dict__ returns
Looping through the same returned dictproxy gives attributes of superclass.
What am i doing wrong?
On Fri, Mar 12, 2010 at 12:15 AM, Gabriel Genellina
wrote:
> En Thu, 1
En Thu, 11 Mar 2010 01:47:30 -0300, Radhakrishna Bhat
escribió:
I am using getattr to get a method instance from a class. But it also
returns methods from the superclass. How to detect if an attribute is
from
superclass?
You may look it up directly in the class dictionary (__dict__)
--
Ga
Thanks. I just have to check in that string if method1 is from present in
subclass's __dict__ or not.
This is important for me because in my code, I am dynamically calling
methods of 2 classes where one is superclass of the other. And I was getting
duplicate results because of this problem.
-Radha
Radhakrishna Bhat wrote:
> I am using getattr to get a method instance from a class. But it also
> returns methods from the superclass. How to detect if an attribute is
> from superclass?
>
You could try, if x is in instance, looking to see whether the name is
defined in x.__class__.__dict__.
>>
I am using getattr to get a method instance from a class. But it also
returns methods from the superclass. How to detect if an attribute is from
superclass?
-Radhakrishna
--
http://mail.python.org/mailman/listinfo/python-list