super() in class defs?

Eric Snow ericsnowcurrently at gmail.com
Wed May 25 16:49:07 EDT 2011


On Wed, May 25, 2011 at 12:31 PM, Ian Kelly <ian.g.kelly at gmail.com> wrote:

> On Wed, May 25, 2011 at 11:54 AM, Jess Austin <jess.austin at gmail.com>
> wrote:
> > So I guess that when super() is called in the context of a class def
> > rather than that of a method def, it doesn't have the information it
> > needs. Now I'll probably just say:
> >
> >    do_GET = do_decorate(CGIHTTPRequestHandler.do_GET)
> >
> > but I wonder if there is a "correct" way to do this instead? Thanks!
>
> I would recommend against using super() in general.
>
>
That position is understandable.  However, super is fine for single
inheritance, and works fine in cooperative multiple inheritance.  You can
just as easily argue that multiple inheritance is more harmful than super
is.  If fact, I would generally recommend against using multiple inheritance
if you can avoid it (though it has its place).

Personally, I find super to make maintenance and refactoring easier, since I
don't have to fiddle with the base class name, or with passing self.

Cheers,

-eric


> http://fuhm.net/super-harmful/
>
> Cheers,
> Ian
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110525/52dc656e/attachment-0001.html>


More information about the Python-list mailing list