[Python-3000] Problems with the new super()

Georg Brandl g.brandl at gmx.net
Fri May 2 05:28:19 CEST 2008


Guido van Rossum schrieb:
> On Thu, May 1, 2008 at 11:20 AM, Georg Brandl <g.brandl at gmx.net> wrote:
>>  But the other two magical things about super() really bother me too. I
>>  haven't looked at the new super in detail so far (and I don't know how
>>  many others have), and two things are really strikingly unpythonic in
>>  my view:
>>
>>  * super() only works when named "super" [1]. It shouldn't be a function if
>>   it has that property; no other Python function has that.
> 
> Actually, I believe IronPython and/or Jython have to use this trick in
> certain cases -- at least I recall Jim Hugunin talking about
> generating different code when the use of locals() was detected.

I don't know if it's possible in Jython to have "locals" referring to
something else. For CPython, the name "super" in a function can refer to
anything -- local, global or builtin -- and it just feels wrong for the
compiler to make assumptions based on the mere mention of a non-reserved
name.

> I'm not proud of this, but I don't see a way around it. The
> alternative would be to make it a keyword, which seemed excessive
> (plus, it would be odd if super() were a keyword when self is not).

I don't find it odd. In fact, IMO the whole magic needed for the runtime
implementation of "super()" justifies super becoming a keyword.

Georg

[Moving this to the Python-3000 list]

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.



More information about the Python-3000 mailing list