Python Regex Syntax [2-Minute Primer]

A regular expression is a decades-old concept in computer science. Invented in the 1950s by famous mathematician Stephen Cole Kleene, the decades of evolution brought a huge variety of operations. Collecting all operations and writing up a comprehensive list would result in a very thick and unreadable book by itself. Fortunately, you don’t have to learn all regular expressions before you can start using them in your practical code projects. Next, you’ll get a quick and dirty overview of the most important regex operations and how to use them in…

Read More

PyGame: A Primer on Game Programming in Python

When I started learning computer programming late in the last millennium, it was driven by my desire to write computer games. I tried to figure out how to write games in every language and on every platform I learned, including Python. That’s how I discovered pygame and learned how to use it to write games and other graphical programs. At the time, I really wanted a primer on pygame. By the end of this article, you’ll be able to: Draw items on your screen Play sound effects and music Handle…

Read More

A 3-Min Primer on Python Decorators

Say, you are working for a large bank. Your hacker colleague implemented a magic function that uses SSH to log into the bank’s core server (written in COBOL which you don’t know at all), analyzes the CPU usage over the last 24 hours, and returns the result as a cryptic string value. Your boss asks you to modify the magic function so that it returns an integer value that is easier to process. In other words, your secondary bank application (written in Python) expects from now on that every call…

Read More