[Python-ideas] simpler super() syntax
Szekeres István
szekeres at iii.hu
Fri Feb 22 12:30:35 CET 2008
Hi,
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.
>
>From Blah.__init__ how would you call super(Blah, self).__init__ if you
explicitely do not want to pass any arguments to it?
super(Blah, self).__init(*[],**{}) ? :)
If your only concern is that you have to type "*args, **kwds" too many
times, maybe something the following could be introduced:
def __init__(*):
super(Blah, self).__init__(*)
so * would mean whatever argument is given to the function.
Or we similarly to *args and **kwds possibly the new syntax ***allargs could
be introduced which would mean a tuple of *args and **kwds. That could be
abbreviated as ***a -> it is much sorter and easier to type, yet it is
implicit.
Istvan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-ideas/attachments/20080222/266efde5/attachment.htm
More information about the Python-ideas
mailing list