[Python-ideas] simpler super() syntax

Guido van Rossum guido at python.org
Fri Feb 22 17:12:31 CET 2008


(a) In Py3k, you will be able to use super() itself without args, e.g.
super().__init__(*args)

(b) There are lots of reasons why you would not want to pass the args
to your super method *unchanged*. Also, super methods may have
defaults for all args. So super.__init__() would be ambiguous -- does
he want to pass all args or none?

Because of this I am strongly against this.

On Fri, Feb 22, 2008 at 12:53 AM, Arne Babenhauserheide <arne_bab at web.de> wrote:
> Hi,
>
>  I just spent some time figuring out how and why super needs to be called with
>  *args and **kwds in any class, when I use multiple inheritance (or when some
>  subclass wants to use it), and I got the impression, that simply every class
>  should take *args and **kwds and that super should be called inside the init
>  of every class.
>
>  Would it make sense to make the init of any class take *args and **kwds
>  implicitely?
>
>  With that, arguments and keywords would always be passed on (the behaviour we
>  need as soon as we use any multiple inheritance) and the code would look
>  cleaner (I think).
>
>
>  At the moment the code for a class with MI looks like this:
>
>  class Blah(Blubb):
>         def __init__(*args, **kwds)
>                 super(Blah, self).__init__(*args, **kwds)
>
>  with implicit *args and **kwds, it would look like this:
>
>  class Blah(Blubb):
>         def __init__()
>                 super(Blah, self).__init__()
>
>  And by calling super, I implicitely say, that i want to pass on any leftover
>  args or kwds which (to my knowledge) I must do anyway, since else I am in
>  danger of getting MI bugs.
>
>  What do you think?
>
>  Best wishes,
>  Arne
>  --
>  Unpolitisch sein
>  Heißt politisch sein
>  Ohne es zu merken.
>  - Arne Babenhauserheide ( http://draketo.de )
>  -- Weblog: http://blog.draketo.de
>
>  -- Mein öffentlicher Schlüssel (PGP/GnuPG):
>  http://draketo.de/inhalt/ich/pubkey.txt
>
> _______________________________________________
>  Python-ideas mailing list
>  Python-ideas at python.org
>  http://mail.python.org/mailman/listinfo/python-ideas
>
>



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-ideas mailing list