Re: OOP: method overriding works in mysterious ways?

2006-01-03 Thread Christophe
John M. Gabriele a écrit : Consider the following: #!/usr/bin/python #- class Grand_parent( object ): def speak( self ): print 'Grand_parent.speak()' self.advise() def advise( self ):

Re: OOP: method overriding works in mysterious ways?

2006-01-03 Thread Chris Mellon
On 1/2/06, Mike Meyer [EMAIL PROTECTED] wrote: John M. Gabriele [EMAIL PROTECTED] writes: Consider the following: #!/usr/bin/python #- class Grand_parent( object ): def speak( self ): print

OOP: method overriding works in mysterious ways?

2006-01-02 Thread John M. Gabriele
Consider the following: #!/usr/bin/python #- class Grand_parent( object ): def speak( self ): print 'Grand_parent.speak()' self.advise() def advise( self ): print 'Grand_parent.advise()'

Re: OOP: method overriding works in mysterious ways?

2006-01-02 Thread Dustan
Parent.critique() is calling self.critique(), which has been overriden by Child.critique() instead of Parent.critique. It makes perfect sense to me. -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP: method overriding works in mysterious ways?

2006-01-02 Thread Dustan
Oh, I see what you mean. From my experience, the methods are passed down, not referred to from the parent. That is, Parent does have its own critique method, not a reference to Grand_parent.critique(). So when Child calls self.advise, it is calling its inherrited copy. Then, since the inherited

Re: OOP: method overriding works in mysterious ways?

2006-01-02 Thread André
John M. Gabriele wrote: Consider the following: [snip] #- class Parent( Grand_parent ): def speak( self ): print '\tParent.speak()' self.advise() def advise( self ): print

Re: OOP: method overriding works in mysterious ways?

2006-01-02 Thread Dustan
it calls it's own overriden critique method (overriden meaning the one that did the overriding) -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP: method overriding works in mysterious ways?

2006-01-02 Thread Scott David Daniels
Dustan wrote: From my experience, the methods are passed down, not referred to from the parent. That is, Parent does have its own critique method, not a reference to Grand_parent.critique(). This is typical of static binding as (for example) seen in C++. If you think of dynamically bound

Re: OOP: method overriding works in mysterious ways?

2006-01-02 Thread John M. Gabriele
Scott David Daniels wrote: Dustan wrote: From my experience, the methods are passed down, not referred to from the parent. That is, Parent does have its own critique method, not a reference to Grand_parent.critique(). This is typical of static binding as (for example) seen in C++.

Re: OOP: method overriding works in mysterious ways?

2006-01-02 Thread John M. Gabriele
Dustan wrote: [snip] That is, Parent does have its own critique method, not a reference to Grand_parent.critique(). Interesting. It has its own critique method? Hm. Not quite sure what that means exactly... Anyhow, I wasn't suggesting that Parent had a reference to Grand_parent.critique(),

Re: OOP: method overriding works in mysterious ways?

2006-01-02 Thread John M. Gabriele
André wrote: John M. Gabriele wrote: Since Child has no advice() method, it inherits the one for Parent. Thus, Child can be thought of as being defined as follows: . class Child( Parent ): . . def speak( self ): . print '\t\tChild.speak()' . self.advise() . .

Re: OOP: method overriding works in mysterious ways?

2006-01-02 Thread Mike Meyer
John M. Gabriele [EMAIL PROTECTED] writes: Consider the following: #!/usr/bin/python #- class Grand_parent( object ): def speak( self ): print 'Grand_parent.speak()' self.advise() def advise(