Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Aahz
In article <[EMAIL PROTECTED]>, Roel Schroeven <[EMAIL PROTECTED]> wrote: > >I used to interpret the target in 'The target is only evaluated once' >more like an L-value in C/C++. That's not correct, of course, but I >didn't understand exactly how wrong it was until now. It's true almost everywh

Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Aahz
In article <[EMAIL PROTECTED]>, OKB (not okblacke) <[EMAIL PROTECTED]> wrote: > > This sentence is phrased as though it is the whole story, but it >isn't, because the operation might not in fact wind up being an >assignment. Shouldn't there be an "except see below" or something >there, to

Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Roel Schroeven
OKB (not okblacke) schreef: > Aahz wrote: > >>> tup=([],) >>> tup[0] += ['zap'] Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assignment > >> Obviously, you can easily work around it: >> > t = ([],) > l = t

Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread OKB (not okblacke)
Aahz wrote: >> tup=([],) >> tup[0] += ['zap'] >>> Traceback (most recent call last): >>> File "", line 1, in >>> TypeError: 'tuple' object does not support item assignment > Obviously, you can easily work around it: > t = ([],) l = t[0] l += ['foo'] t > (['foo'],)

Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Roel Schroeven
Aahz schreef: def foo(bar): bar[0] += ['zap'] > ... import dis dis.dis(foo) > 1 0 LOAD_FAST0 (bar) > 3 LOAD_CONST 1 (0) > 6 DUP_TOPX 2 > 9 BINARY_SUBSCR > 10 LOAD_

Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Aahz
In article <[EMAIL PROTECTED]>, Roel Schroeven <[EMAIL PROTECTED]> wrote: >Aahz schreef: >> >> Although Alex is essentially correct, the situation is a bit more complex >> and you are correct that augmented assignment allows the object to decide >> whether to mutate in place. However, the critic

Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Roel Schroeven
Aahz schreef: > In article <[EMAIL PROTECTED]>, > Neil Cerutti <[EMAIL PROTECTED]> wrote: >> On 2007-08-11, Alex Martelli <[EMAIL PROTECTED]> wrote: >>> Neil Cerutti <[EMAIL PROTECTED]> wrote: >>>... The Python Language Reference seems a little confused about the terminology. >>

Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Aahz
In article <[EMAIL PROTECTED]>, Neil Cerutti <[EMAIL PROTECTED]> wrote: >On 2007-08-11, Alex Martelli <[EMAIL PROTECTED]> wrote: >> Neil Cerutti <[EMAIL PROTECTED]> wrote: >>... >>> The Python Language Reference seems a little confused about the >>> terminology. >>> >>> 3.4.7 Emulating nume