[Python-Dev] [Python-3000] Pre-pre PEP for 'super' keyword (original) (raw)

Calvin Spealman ironfroggy at gmail.com
Mon Apr 30 00:23:52 CEST 2007


On 4/29/07, Jim Jewett <jimjjewett at gmail.com> wrote:

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.

I will incorporate this into my draft, particularly taking care of the issue with inner functions.

> 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?

I would like to say super becomes a constant in the way that None is a constant, and if there is some reason the implementation today or tomorrow can benefit from actually making it a keyword, that won't break anything if its already constant. One problem with an actual keyword, is there is no other part of Python where an actual keyword evaluates to something.

> 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)

This might run into the same issue I had to cover, where you get an ambiguous situation trying to distinguish between calling super and calling the call method of the next class in the MRO.

We should absolutely avoid a situation in python now where X() differs from X.call()

> 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

I sure wish my previous complaints didn't hinder this, because I really love the idea of being able to this, which would really encourage more compatible method signatures, so you can use the shortcut! I'm desperate for a solution that satisfies all the sides of the equation.

vs

def init(self, myvar, passedvar): super.init(self, passedvar) # flags that you are changing the args -jJ

-- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://ironfroggy-code.blogspot.com/



More information about the Python-Dev mailing list