super with only one argument
Greg Chapman
glc at well.com
Thu Mar 17 10:04:40 EST 2005
Greg Chapman wrote:
> Steven Bethard wrote:
>
> > When would you call super with only one argument? The only examples
> > I can find of doing this are in the test suite for super.
> >
>
> I think it's to allow something like this:
>
> class A(B, C):
> __super = super(A)
> def foo(self):
> return self.__super.foo()
>
> This allows you to rename A and only have to change one super call to
> reflect the new name.
>
Except that doesn't work unless you use something like the autosuper
metaclass trick from test_descr.py (since the class A does not yet
exist where I put that super call). And autosuper has a comment that
it "only works for dynamic classes" -- not sure that I understand what
"dynamic" means there.
In case you haven't guessed by now, I've only used two-arg super in my
own code.
---
Greg Chapman
More information about the Python-list
mailing list