The Invent with Python Blog

Writings from the author of Automate the Boring Stuff.


Fri 17 August 2018

The Zen of Python, Explained

Posted by Al Sweigart in python   

The Zen of Python by Tim Peters are 20 guidelines for the design of the Python language. Your Python code doesn’t necessarily have to follow these guidelines, but they’re good to keep in mind. The Zen of Python is an Easter egg, or hidden joke, that appears if you run import this.

Read more...


Mon 21 May 2018

Python's Fake Increment and Decrement Operators

Posted by Al Sweigart in python   

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...















Thu 20 November 2014

IDLE Reimagined

Posted by Al Sweigart in python   

IDLE Reimagined is the project name for a redesign for Python's default IDLE editor with focus as an educational tool. IDLE's chief utility is that it comes installed with Python, making it simple for newbies to start programming. But professional software developers don't use IDLE as their IDE. Instead of turning IDLE into a sophisticated IDE for professional software developers, it can be tooled with features specifically to make it friendly to those learning to program.

Read more...


Tue 30 September 2014

No, Seriously, Why Should I Learn to Code?

Posted by Al Sweigart in programming   

The geeks have inherited the earth. A couple decades ago if you talked with friends in a chat room, you were cast as a socially-awkward nerd. Doing the same today just means you're a typical Facebook user. Broadband Internet connections and smartphones have taken the Information Age that technically started in the 1970s with PCs and pushed it into daily mainstream life.

Don't get me wrong: You should learn to program. But lost in this hype is a plainspoken reason: NO, SERIOUSLY, WHY SHOULD I LEARN TO CODE?

Read more...



Sun 15 December 2013

Why Is HTML Not A Programming Language?

Posted by Al Sweigart in programming   

HTML is not a programming language. You can't write a "program" that, say, calculates the average of ten numbers with HTML. While some may point out that HTML is a "markup language", this doesn't clarify how that is different from a programming language. This isn't meant to be a thorough argument, but rather a brief explanation that goes just a bit more in detail than "HTML isn't a programming language but instead a markup language."

Read more...