Super() function

alex23 wuwei23 at
Thu Mar 25 04:47:19 CET 2010

Alan Harris-Reid <aharrisr... at> wrote:
> Is there any way of writing the code so that the super() call is generic
> and automatically recognises the name of the current method (ie.
> something like super().thismethod()) or do I always have to repeat the
> method name after super()?

To the best of my knowledge, you always need to repeat the method
name. super() returns a proxy object that has no awareness of its
context, so it's unaware of the method it's being called within (in
fact, there's nothing that restricts super() to only being used in

You could probably write a wrapper function that uses inspect to
determine in which context super() is being called, but unless you're
regularly finding this to be a problem with refactoring I wouldn't
worry about it.

More information about the Python-list mailing list