Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 2nd, 2002, 12:25 PM
vpopper's Avatar
vpopper vpopper is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: Southern California
Posts: 73 vpopper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 24 sec
Reputation Power: 9
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?

Reply With Quote
  #2  
Old October 3rd, 2002, 03:56 PM
ZeUs's Avatar
ZeUs ZeUs is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: St. George, Utah
Posts: 63 ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 31
Re: newbie operator question

Quote:
Was it not available in previous versions


Yep, that's it. It was not available in Python 1.x versions.
__________________
Lucas Marshall

Reply With Quote
  #3  
Old October 7th, 2002, 11:35 PM
CaitlinG CaitlinG is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 9 CaitlinG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > newbie operator question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT