[Python-Dev] surprised to "++" and "--"
gherron at islandtraining.com
Fri Sep 25 17:09:11 CEST 2009
(Moving this to python-list where it should have been in the first place).)
As pointed out, var++ and var-- are syntax errors, however several
similar expressions are legal. These, however, are not interpreted as
the C++ increment and decrement operators, but rather as a binary
operator followed by a unary operator or two unary operators.
++a, --a, a++b, a--b are all legal and interpreted as +(+a), -(-a),
a+(+b), and a-(-b).
Could it be from one of these that the OP formed his (mistaken) idea?
Facundo Batista wrote:
> 2009/9/23 Wee Binn <weebinn at gmail.com>:
>> I know that there is no "++" or "--" operator in python, but if "var++"
>> or something like that in my code(you know, most of C/C++ coders may like
>> this),there is nothing wrong reported and program goes on just like
>> This is obscure, maybe a bug.
> You can not write "var++":
>>>> var = 5
> File "<ipython console>", line 1
> SyntaxError: invalid syntax
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list