October 2nd, 2002, 12:25 PM
newbie operator question
I'm new to python, and part of my learning process is looking at the code of more experienced python programmers. One thing I see quite often that appears strange is this idiom:
lineno = lineno + 1
Is there a reason why is should not be written:
lineno += 1
This seems to work fine in v2.2, Was it not available in previous versions, or is there something I'm missing?
October 3rd, 2002, 03:56 PM
Re: newbie operator question
Yep, that's it. It was not available in Python 1.x versions.
October 7th, 2002, 11:35 PM
The syntax is a little different but it accomplishes the same thing. ( Adding one to the value on the left ( the 'lvalue' ) ).
You can quite easily add, subtract, etc. almost any value:
total += 5
total -= 5
total *= 15
Hope this helps,