Augmented Assignement (was: Re: PEP scepticism)
root at rainerdeyke.com
Mon Jul 2 13:32:03 EDT 2001
"Aahz Maruch" <aahz at panix.com> wrote in message
news:9hq4c7$e7h$1 at panix3.panix.com...
> In article <naO%6.416271$oc7.58537852 at news2.rdc2.tx.home.com>,
> Rainer Deyke <root at rainerdeyke.com> wrote:
> >"Courageous" <jkraska1 at san.rr.com> wrote in message
> >news:q0avjto87p59hn7gv28r5cf1c84j2fb8c7 at 4ax.com...
> >> 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 rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
More information about the Python-list