Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Name

Syntax Example

Comments

Member

A.B

Classes are described in Part 08 - Classes

Function Call

f(x)

Functions are described in Part 07 - Functions

Post Increment

i++

See Difference between Pre and Post Increment/Decrement

Post Decrement

i--

See Difference between Pre and Post Increment/Decrement

Constructor Call

o = MyClass()

Classes are described in Part 08 - Classes

...

Name

Syntax Example

Comments

Negative Value

-5

Pre Increment

++i

See Difference between Pre and Post Increment/Decrement

Pre Decrement

--i

See Difference between Pre and Post Increment/Decrement

Grouping

(a + b)

Difference between Pre and Post Increment/Decrement
Anchor
Difference between Pre and Post Increment/Decrement
Difference between Pre and Post Increment/Decrement

When writing inline code, Pre Increment/Decrement (+i/-i) commit the action, then return its new value, whereas Post Increment/Decrement (i+/i-) return the current value, then commit the change.

Code Block
borderStylesolid
titlepreincrement vs. postincrement
borderStylesolid
num = 0
for i in range(5):
    print num++
print '---'
num = 0
for i in range(5):
    print ++num
No Format
bgColor#D8DDE9
titleOutput
borderStylesolid
titleOutput
0
1
2
3
4
---
1
2
3
4
5
Tip
titleRecommendation

To make your code more readable, avoid using the incrementors and decrementors.
Instead, use i += 1 and i -= 1.

...