[Python-Dev] why do we allow this syntax?
catch-all at masklinn.net
Fri Feb 8 16:50:42 CET 2013
On 2013-02-08, at 16:39 , Chris Withers wrote:
> Hi All,
> Just had a bit of an embarrassing incident in some code where I did:
> sometotal =+ somevalue
> I'm curious why this syntax is allowed? I'm sure there are good reasons, but thought I'd ask…
sometotal = (expression) is valid syntax, and +value is valid syntax.
Thus what you wrote is perfectly normal syntax, it's the assignment of a
pos'd value, badly formatted. pep8.py will warn against it (it'll
complain that the whitespace around `+` is wonky). But I see no
justification for disallowing this, anymore than for disallowing the
rougly equivalent (and just as error-prone) `sometotal = -somevalue`.
More information about the Python-Dev