Accessing parent objects

Chris Angelico rosuav at gmail.com
Sun Mar 25 17:58:36 EDT 2018


On Mon, Mar 26, 2018 at 7:30 AM, Rick Johnson
<rantingrickjohnson at gmail.com> wrote:
>> Especially since by your own admission, you are *giving up
>> correctness* in order to buy "consistency":
>
> "sacrificing correctness" only in a purely ideological
> sense.
>
> Explicit inheritance (aka: hard-coding the superclass
> symbol) works just as well as implicit inheritance (aka:
> relying on the "resolution magic" of super). Of course, in
> the former case, a slight bit of onerous is placed on the
> programmer because he/she must know the exact spelling of
> the superclass symbol, whereas, OO's `super` is nothing but
> a lazy shortcut which looks up and returns the symbol for
> you.

Only, and let me stress that, ONLY, when your classes inherit from
exactly *one* superclass, and you mandate that every class that
inherits from any of your classes ALSO inherits from exactly one
superclass. If *any* class ever inherits from one of your classes and
also something else, hard-coded superclass names become straight-up
wrong.

Have you put code into your classes to prevent anyone from ever
multiply inheriting?

ChrisA



More information about the Python-list mailing list