Re: super in Python 3 and variadic arguments

2013-10-10 Thread Marco Buttu
On 10/11/2013 04:33 AM, Ian Kelly wrote: On Thu, Oct 10, 2013 at 8:11 PM, Steven D'Aprano >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

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Marco Buttu
On 10/11/2013 04:11 AM, Steven D'Aprano wrote: 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

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Chris Angelico
On Fri, Oct 11, 2013 at 2:00 PM, Steven D'Aprano wrote: > I'll now go and write "I will always test my code snippets before > posting" on the blackboard one hundred times. print("I will always test my code snippets before posting\n"*100) ChrisA PS. Irony would be having a bug in that because I

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Steven D'Aprano
On Thu, 10 Oct 2013 20:33:37 -0600, Ian Kelly wrote: > On Thu, Oct 10, 2013 at 8:11 PM, Steven D'Aprano > 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

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Ian Kelly
On Thu, Oct 10, 2013 at 8:11 PM, Steven D'Aprano 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 wi

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Steven D'Aprano
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 late

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Marco Buttu
On 10/10/2013 01:04 PM, Ned Batchelder wrote: On 10/10/13 3:22 AM, Marco Buttu wrote: >>> import inspect >>> class B(A): ... def bfoo(*args): ... frame = inspect.currentframe() ... for obj, value in frame.f_locals.items(): ... print(obj, value, sep=' --> ') ...

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Ned Batchelder
On 10/10/13 3:22 AM, Marco Buttu wrote: On 10/09/2013 06:47 PM, Ned Batchelder wrote: >>> class B(A): ... def bfoo(*args): ... super().afoo(*args[1:]) ... >>> B().bfoo(1, 2, 3) Traceback (most recent call last): File "", line 1, in File "", line 3, in bfoo RuntimeError: super()

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Marco Buttu
On 10/09/2013 06:47 PM, Ned Batchelder wrote: >>> class B(A): ... def bfoo(*args): ... super().afoo(*args[1:]) ... >>> B().bfoo(1, 2, 3) Traceback (most recent call last): File "", line 1, in File "", line 3, in bfoo RuntimeError: super(): no arguments How come? The no-args s

Re: super in Python 3 and variadic arguments

2013-10-09 Thread Ned Batchelder
On 10/9/13 11:44 AM, Marco Buttu wrote: Given this class: >>> class A: ... def afoo(*args): ... print(args) in Python 3 we can write the following class: >>> class B(A): ... def bfoo(*args): ... super(B, args[0]).afoo(*args[1:]) ... >>> B().bfoo(1, 2, 3) (<__main__.B ob