(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?

Gary Herron



Facundo Batista wrote:
2009/9/23 Wee Binn <weeb...@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
expected!!
    This is obscure, maybe a bug.

You can not write "var++":

var = 5
var++
   File "<ipython console>", line 1
     var++
          ^
SyntaxError: invalid syntax

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to