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
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
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
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
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
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
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=' --> ')
...
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()
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
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
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 object at 0x7f5b3bde48d0>, 1, 2, 3)
witho
11 matches
Mail list logo