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