|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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? |
|
#2
|
||||
|
||||
|
Re: newbie operator question
Quote:
Yep, that's it. It was not available in Python 1.x versions.
__________________
Lucas Marshall |
|
#3
|
|||
|
|||
|
Hi Vpopper.
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, -Caitlin. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > newbie operator question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|