Augmented Assignement (was: Re: PEP scepticism)

Steve Holden sholden at holdenweb.com
Mon Jul 2 12:44:05 EDT 2001


"Courageous" <jkraska1 at san.rr.com> wrote in message
news:fr81ktskiqe8guj9b241qd9mtq1324bfkd at 4ax.com...
>
> >> x += (1,2,3)  ... is not the same as...  x=x+(1,2,3)
> >> That's just plain wrong.
>
> >No, that's the *whole intent* of the thing.
>
> Intent involves what people were thinking when they asked for it.
> I have a strong feeling that you are quite wrong about this.
>
I agree. The interpreter's current behavior is, as was explained to me in
some detail when I made similar complaints (*before* the PEP was
implemented, but after it was approved, and so therefore too late to do
anything but waste time :-( ) exactly what was intended.

Besides which, for a tuple x then x += (1,2,3) is, *exactly*, the same as x
= x+(1,2,3), since both involve a rebinding of the name x to a new tuple
containing three additional elements. Previous references to the original
tuple will still point to it, unchanged.

It's mutable types whose behavior can differ. Unless I'm being incredibly
dumb.

and-it-wouldn't-be-the-first-time-if-i-were'ly y'rs  - steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list