#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Southern California
    Posts
    73
    Rep Power
    14

    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. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    St. George, Utah
    Posts
    63
    Rep Power
    37

    Re: newbie operator question


    Was it not available in previous versions
    Yep, that's it. It was not available in Python 1.x versions.
    Lucas Marshall
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    9
    Rep Power
    0
    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.

IMN logo majestic logo threadwatch logo seochat tools logo