Flagging classes as not intended for direct initialization

Ian Kelly ian.g.kelly at gmail.com
Mon Feb 16 06:59:48 EST 2015


On Mon, Feb 16, 2015 at 3:55 AM, Mario Figueiredo <marfig at gmail.com> wrote:
> In article <54e14cfe$0$12997$c3e8da3$5496439d at news.astraweb.com>,
> steve+comp.lang.python at pearwood.info says...
>> Unless you have good reason not to, you should use super rather than
>> directly call the superclass.
>>
>> https://rhettinger.wordpress.com/2011/05/26/super-considered-super/
>
> It's not been an easy ride trying to decide whether or not to use super.
> I started learning python from a Mark Lutz book that advised me against
> it. And on the web I get all sorts of information pro and against. Seems
> like everyone has an opinion and theirs the correct one.
>
> I have not delved deep into that construct to decide for myself. But
> thanks for the link. It actually addresses more than most and builds a
> pretty good case for it.

There's nothing inherently bad about super itself, other than the name
being slightly misleading. For single inheritance hierarchies, there
is no reason at all not to use it -- particularly in Python 3 where
you don't even have to pass it arguments. It was designed to resolve
the diamond problem in multiple inheritance situations, though, and
while super does a fine job of that, it doesn't solve the basic
problem that multiple inheritance is usually a bad idea to start with
that ends up as a complicated, confusing mess.

Use super for superclass calls, avoid multiple inheritance, and you'll
have no problems.



More information about the Python-list mailing list