Augmented Assignement (was: Re: PEP scepticism)

Rainer Deyke root at
Mon Jul 2 13:32:03 EDT 2001

"Aahz Maruch" <aahz at> wrote in message
news:9hq4c7$e7h$1 at
> In article <naO%6.416271$oc7.58537852 at>,
> Rainer Deyke <root at> wrote:
> >"Courageous" <jkraska1 at> wrote in message
> >news:q0avjto87p59hn7gv28r5cf1c84j2fb8c7 at
> >>
> >> def f(x):
> >>     x = x + (1,2,3)
> >> print x
> >>
> >> ?
> >
> >A vast improvement: clear, unambiguous, and correct.  I can safely pass a
> >list as an argument and not have it modified behind my back.  Having to
> >write "x" twice on the second line is not good, but if it buys me
> >correctness, I'll happily pay that price.
> In what version of Python can you pass a list to f() here?

Not sure (though, since you asked, I'd guess none), but that's not really
the point.  If I pass a list and the function doesn't like it, I get an
exception telling me exactly what went wrong and how I need to fix it.  If I
pass a list to the other version, I get subtly (or not so subtly) incorrect

Rainer Deyke (root at
Shareware computer games           - 
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

More information about the Python-list mailing list