Company
Date Published
Author
Bob Belderbos
Word count
378
Language
English
Hacker News points
None

Summary

Mike Pirnat's ebook, "How to Make Mistakes in Python," offers a collection of useful tips to help Python programmers improve their coding practices. It emphasizes the importance of using virtual environments like virtualenv or pyvenv to isolate projects, and suggests using IPython or Jupyter Notebooks instead of the default REPL for efficiency. The guide advises adhering to PEP 8, Python's style guide, and highlights the significance of meaningful variable names and avoiding overly complex constructs such as excessive nesting in lambdas, list comprehensions, and decorators. It recommends replacing long if/elif blocks with classes or dictionaries and using Enums, and suggests using properties instead of extensive getters and setters. The book also warns against the global scope, encourages explicit imports, and advises against using mutable default argument values in functions. It stresses the importance of testing, recommends using frameworks like pytest, and underscores the utility of logging. Pirnat's insights are shared in a concise 80-page ebook, celebrating the ethos of "Keep Calm and Code in Python."