Pydon'ts

Write beautiful Python code

Buy the book on Leanpub or read the articles here.

  9366

for loops are the bread and butter of imperative programming and Python has some really nice tools to work with them. If you want to traverse several structures in parallel, have you considered using zip?

Structural pattern matching is coming in Python 3.10 and the previous Pydon't explored some interesting use cases for the new match statement. This article explores situations for which match isn't the answer.

Structural pattern matching is coming in Python 3.10 and this article explores how to use it to write Pythonic code, showing the best use cases for the match statement.

Python's comparisons operators can be chained to shorten common comparison expressions. Learn the ins and outs of comparison operator chaining and especially the cases you should avoid, namely those where you chain comparison operators that aren't aligned.