Why self?
Lou Pecora
pecora at anvil.nrl.navy.mil
Tue Jul 9 17:13:28 EDT 2002
In article <agfb5204pg at enews3.newsguy.com>, Charles Hixson
<charleshixsn at earthlink.net> wrote:
> Let's be explict:
> from __future__ import nested_scopes
> class A:
> def ma(self):
> print "ma, ma"
> def pa(self):
> self.ma()
> class B(A):
> def ma():
> print "hello, world"
> tst = B()
> tst.pa()
>
> Testing this produces the message, "hello, world"
> This seems to be the wrong message. The version of pa that was called
> was the version defined in class A, so the routine called should have
> been the routine defined in class A.
??? This is the one I would expect to be called, B.pa. Same rule for
C++, IIRC. The inherited displaces the ancester. Sounds "logical" to
me.
Q. Is the ancester accessible? Like B.A.pa() ? It is in C++ using
the scope operator, I think
More information about the Python-list
mailing list