super in Python 3 and variadic arguments
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Thu Oct 10 22:11:19 EDT 2013
On Thu, 10 Oct 2013 07:04:38 -0400, Ned Batchelder wrote:
> super() with no args is a kind of hack to begin with. It involves a
> special case in the compiler (so that using the name "super" as a
> function call will act as if you had accessed the name "__class__" so
> that super can find it later), and inspecting the stack frame during
> execution.
super() with no arguments is *completely* a hack[1], and one where GvR
has said "Never again!" if I remember correctly. I don't think he regrets
allowing the super compile-time magic, just that it really is magic and
he doesn't want to make a habit of it.
One of the side-effects of this being a hack is that this doesn't work:
class X(Y):
def method(self, arg):
f = super
f().method(arg)
[1] Which is not necessarily a bad thing!
--
Steven
More information about the Python-list
mailing list