Is there a way to 'mask out' inherited methods?

Ralf Juengling juenglin at informatik.uni-freiburg.de
Sun May 5 09:59:40 EDT 2002


"Steve Holden" <sholden at holdenweb.com> writes:

> 
> > What happens -- in terms of descriptors -- when the
> > following expressions are evaluated? (Imagine the del
> > statement in B.__init__ is absent and):
> >
> > b = B()
> >
> > 1. b.mA()
> 
> The mA() method inherited from A is called as described above, with b as its
> first argument.
> 
> > 2. b.mB()
> 
> The B.mB() method is called, with b as its first argument.
> 
> >
> > 3. b.mA = 'eat that'
> 
> New-style: nono. Classic: binds an instance-local "mA" attribute to the
> string. This attribute masks the mA inherited from the class's superclass,
> since the search willl now be satisfied by the instance's local namespace.
> 
> > 4. b.mB = 'or that'
> 
> Same as for 3, except that the name that is masked is defined in the
> instance's class definition.
> 
> >
> > 5. del b.mA
> > 6. del b.mB
> >
> Do you mean after 1-4, or independently of them? Seriously, I would hope you
> could work that out for yourself by now. If not, please feel free to post
> again.

To state my question more precisely: I anticipate any of the following
expressions to be translated into one or the other call to the 
'descriptor API' by the Python interpreter. 
I just want to understand into exactly which calls (treating the expressions 
independently).

1. b.mA()
2. b.mB()

3. b.mA = 'eat that'
4. b.mB = 'or that'

5. del b.mA
6. del b.mB


Thanks,
Ralf



More information about the Python-list mailing list