Mon 21 May 2018

Python's Fake Increment and Decrement Operators

Posted by Al Sweigart in misc   

In Python, you can increase the value of a variable by 1 or reduce it by 1 using the augmented assignment operators. The code spam += 1 and spam -= 1 increments and decrements the numeric values in spam by 1, respectively.

Other languages such as C++ and Java have the ++ and -- operators for incrementing and decrementing variables. (The name of C++ itself reflects this; the name is a tongue-in-cheek joke that indicates it's an enhanced form of the C language.) Code in C++ and Java could have ++spam or spam++. Python wisely doesn't include these operators; they are notoriously susceptible to subtle bugs.

Read more...



Fri 02 February 2018

How To Ask For Programming Help

Posted by Al Sweigart in misc   

I often get emails say little more than "Why doesn't my program work?" Often I can't answer them; either I don't have enough information about your problem or you're asking me about something I don't know anything about.

Read more...