[Python-3000] Fixing super anyone?

Collin Winter collinw at gmail.com
Tue Apr 24 03:03:31 CEST 2007


On 4/23/07, Jim Jewett <jimjjewett at gmail.com> wrote:
[snip]
> If we're willing to put up with the magic, then it would work to make
> super syntactic sugar for
>
>     super(__this_class__, self)
>
> At the moment, I can't see anything wrong with this, but I have a
> feeling I'm missing something about how the super object should behave
> on its own.

You mean, have "super.method_name(*args)" expanded by the AST compiler
into super(__this_class__, self).method_name(*args)"? The object
reference -> function call change is too much magic; -1.

However, having the AST compiler expand

class A:
  def m(self):
    blah()
    super(self).m()
    blah()

to

class A:
  def m(self):
    super = super_factory(A)
    blah()
    super(self).m()
    blah()

strikes me as an "appropriate" amount of magic. Restricting the magic
to a source transformation should enable other Python implementations
to implement this relatively easily.

Collin Winter


More information about the Python-3000 mailing list