PEP 245

Alex Martelli aleaxit at yahoo.com
Tue Apr 3 09:37:21 EDT 2001


"Paul Robinson" <paul.robinson at businesscollaborator.com> wrote in message
news:mailman.986302445.8830.python-list at python.org...
>
>
> Alex Martelli wrote:
> >
> > "Alex Shindich" <shindich at itginc.com> wrote in message
> > news:mailman.986255463.27488.python-list at python.org...
> > > >in C++, one normally uses _private_ inheritance for this specific
purpose
> > > There is nothing private in Python. There is "__" name mangling of
course,
> > > but that is it.
> >
> > Exactly.  In particular, '__' name mangling does not apply to
inheritance.
>
> What exactly did you mean by that?

That there is no "__ name mangling" to give the effect of private
inheritance, as mentioned in the very first line above.  Names of
attributes starting with __ do get mangled the same way no matter
what inheritance is going to happen or not happen, of course; but
this mangling concept in no way applies to _inheritance itself_,
leaving no Python way to express "private inheritance".

The context, I remind you, was whether it was a good idea to
distinguish "implementing an interface" vs "using another class
in one's implementation", two concepts that C++ somewhat merges
and confuses (but sort-of-separates again by using _private_
inheritance to express 'implemented-in-terms-of').


Alex






More information about the Python-list mailing list