[Python-Dev] [Python-3000] Pre-pre PEP for 'super' keyword

Jim Jewett jimjjewett at gmail.com
Sun Apr 29 23:25:53 CEST 2007


On 4/29/07, Tim Delaney <tcdelaney at optusnet.com.au> wrote:
> I've been intending to write up a PEP for fixing super, but I haven't had
> time to get to it.

Calvin Spealman has the most recent draft. I hope he will incorporate
this into his draft.

> 1. 'super' becomes a keyword, that returns a super object for the instance
> method currently being executed.

So it is a "keyword" in the sense that None is a keyword; not in the
stronger sense that "if" is a keyword?

> 4. super objects are callable, and calling them will execute the super
> method with the same name as the instance method currently being executed.
> Lookup of this method occurs when the instance method is entered.
>
>     class A(object):
>         def f(self):
>             pass
>
>     class B(A):
>         def f(self):
>             super() # Calls A.f(self)

> If you want name lookup to occur at the time of the call, you can explicitly
> specify the method name (just like with any other super attribute):
>
>     class A(object):
>         def f(self):
>             pass
>
>     class B(A):
>         def f(self):
>             super.f() # Calls A.f(self)

As long as you can be explicit, should the shortcut be a full
shortcut?  That is,

    def f(self, a, b=c, *args, **kwargs):
        super()    # passes the exact arglist that f got

vs

    def __init__(self, myvar, passed_var):
        super.__init__(self, passed_var)    # flags that you are
changing the args

-jJ


More information about the Python-Dev mailing list