Python's super() considered super!

Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de
Sat May 28 01:29:48 EDT 2011


Am 28.05.2011 01:57 schrieb sturlamolden:

> Yes. And opposite: CPython cannot know that builtin super() is not
> called,
> even if it does not see the name 'super'. I can easily make foo()
> alias super().

Another alternative would have been to make use of __xxx magic.

If every class had an "automatically available" attribute, e. g. 
__<classname>_classname which thus could be accessed via __classname 
from inside, keeping the 2.x syntax would have been the best, using 
super(__classname, self).


> In both cases, the cure is a keyword -- or make sure that __class__
> is always defined.
>
> If super is to be I keyword, we could argue that self and cls should
> be keywords as well, and methods should always be bound. That speaks in
> favour of a super() function. But then it should always be evaluated at run-
> time, without any magic from the parser.
>
> Magic functions belong in Perl, not Python.

ACK.


Thomas



More information about the Python-list mailing list