SyntaxError: can't assign to a function call
Lawrence Oluyede
raims at dot.com
Sun Feb 26 18:50:03 EST 2006
"Fuzzyman" <fuzzyman at gmail.com> writes:
>>>> f() += [4]
> SyntaxError: can't assign to function call
>>>>
It's obvious that that line gives you a syntax error. += is the increment
operator overloaded for strings and lists and so on. It changes the lhs in
place appending the rhs. In this case the rhs is a function call so... how the
compiler knows how to assign to a function call?
Do the things easily:
- x = f()
- x += [4]
:)
--
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"
More information about the Python-list
mailing list