Re: Finding in which class an object's method comes from

2016-02-04 Thread dieter
"ast" writes: > Suppose we have: > > ClassC inherit from ClassB > ClassB inherit from ClassA > ClassA inherit from object > > Let's build an object: > > obj = ClassC() > > Let's invoke an obj method > > obj.funct() > > funct is first looked in ClassC, then if not found > on ClassB, then ClassA the

Re: Finding in which class an object's method comes from

2016-02-04 Thread Wolfgang Maier
On 04.02.2016 10:00, Chris Angelico wrote: On Thu, Feb 4, 2016 at 7:54 PM, ast wrote: It is strange but I dont have the same result that you: (Python 3.4) class A: def a(self):pass class B(A): def b(self):pass class C(B): def c(self):pass obj = C() obj.a > Curious. It appears

Re: Finding in which class an object's method comes from

2016-02-04 Thread Chris Angelico
On Thu, Feb 4, 2016 at 7:54 PM, ast wrote: > It is strange but I dont have the same result that you: > (Python 3.4) > class A: > > def a(self):pass > class B(A): > def b(self):pass > class C(B): > def c(self):pass > obj = C() > obj.a > > > Curious. It appears to have chan

Re: Finding in which class an object's method comes from

2016-02-04 Thread ast
"Ben Finney" a écrit dans le message de news:mailman.48.1454575803.30993.python-l...@python.org... That's been answered, but I'm curious to know what your program will do with that information? Nothings, I was just wondering. -- https://mail.python.org/mailman/listinfo/python-list

Re: Finding in which class an object's method comes from

2016-02-04 Thread ast
"Chris Angelico" a écrit dans le message de news:mailman.43.1454574987.30993.python-l...@python.org... You can see that by looking at the objects without calling them: class A: ... def a(self): pass ... class B(A): ... def b(self): pass ... class C(B): ... def c(self): pass ... ob

Re: Finding in which class an object's method comes from

2016-02-04 Thread Ben Finney
"ast" writes: > Let's invoke an obj method > > obj.funct() > > funct is first looked in ClassC, then if not found > on ClassB, then ClassA then object If it helps: What you describe is attribute lookup, and it happens whether or not you're going to call the attribute. In other words, you need o

Re: Finding in which class an object's method comes from

2016-02-04 Thread ast
"Chris Angelico" a écrit dans le message de news:mailman.43.1454574987.30993.python-l...@python.org... Is that what you're hoping for? yes, ty -- https://mail.python.org/mailman/listinfo/python-list

Re: Finding in which class an object's method comes from

2016-02-04 Thread Chris Angelico
On Thu, Feb 4, 2016 at 7:25 PM, ast wrote: > Hi > > Suppose we have: > > ClassC inherit from ClassB > ClassB inherit from ClassA > ClassA inherit from object > > Let's build an object: > > obj = ClassC() > > Let's invoke an obj method > > obj.funct() > > funct is first looked in ClassC, then if no

Finding in which class an object's method comes from

2016-02-04 Thread ast
Hi Suppose we have: ClassC inherit from ClassB ClassB inherit from ClassA ClassA inherit from object Let's build an object: obj = ClassC() Let's invoke an obj method obj.funct() funct is first looked in ClassC, then if not found on ClassB, then ClassA then object But is there a command to