[Python-Dev] New Super PEP

Collin Winter collinw at gmail.com
Sun Apr 29 18:06:27 CEST 2007


On 4/28/07, Calvin Spealman <ironfroggy at gmail.com> wrote:
[snip]
> The PEP defines the proposal to enhance the super builtin to work implicitly
> upon the class within which it is used and upon the instance the current
> function was called on. The premise of the new super usage suggested is as
> follows:
>
>     super.foo(1, 2)
>
> to replace the old:
>
>     super(Foo, self).foo(1, 2)
[snip]
> The enhancements to the super type will define a new __getattr__ classmethod
> of the super type, which must look backwards to the previous frame and locate
> the instance object. This can be naively determined by located the local named
> by the first argument to the function. Using super outside of a function where
> this is a valid lookup for the instance can be considered undocumented in its
> behavior.

What if the instance isn't called "self"? PEP 3099 states that "self
will not become implicit"; it's talking about method signatures, but I
think that dictum applies equally well in this case.

Also, it's my understanding that not all Python implementations have
an easy analogue to CPython's frames; have you given any thought to
whether and how PyPy, IronPython, Jython, etc, will implement this?

Collin Winter


More information about the Python-Dev mailing list