super in Python 3 and variadic arguments

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Oct 10 23:00:03 EDT 2013


On Thu, 10 Oct 2013 20:33:37 -0600, Ian Kelly wrote:

> On Thu, Oct 10, 2013 at 8:11 PM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> 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)
> 
> Actually, that works just fine.  The compiler sees that super is
> accessed within the method and creates the closure necessary to make it
> work.  This does fail, however:
> 
> f = super
> class X(Y):
>     def method(self, arg):
>         f().method(arg)



Ah, that's the one! Thanks for the correction.

I'll now go and write "I will always test my code snippets before 
posting" on the blackboard one hundred times.



-- 
Steven



More information about the Python-list mailing list