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 ):
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
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()'
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
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
John M. Gabriele wrote:
Consider the following:
[snip]
#-
class Parent( Grand_parent ):
def speak( self ):
print '\tParent.speak()'
self.advise()
def advise( self ):
print
it calls it's own overriden critique method
(overriden meaning the one that did the overriding)
--
http://mail.python.org/mailman/listinfo/python-list
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
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++.
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(),
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()
.
.
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(
12 matches
Mail list logo