[Python-Dev] PEP 203 Augmented Assignment

Michael Hudson mwh21@cam.ac.uk
Thu, 27 Jul 2000 13:55:19 +0100 (BST)

On Thu, 27 Jul 2000, Guido van Rossum wrote:

> > Here's what happens now:
> > 
> > >>> (a, b, c) += 1,2,3
> > SyntaxError: no augmented assignment to tuple
> > 
> > (Isn't a reference implementation a cool thing ? ;)
> Very nice.  Don't touch that part.

I think quite a lot of the code I wrote in compile.c for my augmented
assignment patch lives on in Thomas's patch, and I was very conservative;
if I couldn't work out what something should mean, I banned it (eg.

a += b += c 

is a syntax error too).  On reflection, I think I got this right.  The
error messages could be imporoved, I suspect.

[snip to a very nearly completely different topic]
> Another alternative that tries to preserve compatibility is to call
> __getslice__(self, start, end) when the step is None, but
> __getslice__(self, start, end, step) when it isn't.  Old code will
> raise a reasonable exception when a step is specified, while
> step-aware code can specify the step as a default argument value of
> 1 or None.

Good idea.  Are lists and tuples going to support seq[a:b:c] anytime soon?
Patches welcome, I'd guess...