Welcome, fellow Pythoneer! This is a small book of Python anti-patterns and worst practices.
Learning about these anti-patterns will help you to avoid them in your own code and make you
a better programmer (hopefully). Each pattern comes with a small description, examples and
possible solutions. You can check many of them for free against your project at QuantifiedCode.
With this link you can also download the pdf version.
Short answer: We think that you can learn as much from reading bad code as you can from reading good one.
Long answer: There is an overwhelming amount of Python books that show you how to do things by focusing on best practices and examples of good code. There are only very few books out there that show you how not to do things. We wanted to change that by providing you with an anti-book that teaches you things which you should never do in practice.
We’re QuantifiedCode, a Berlin-based startup. Our mission is to help programmers write better code! Our first product is an online tool for automated, data-driven code review. When building this tool we learned a lot about code quality in Python and decided to compile our knowledge into this book.
This book contains anti- and migrations pattern for Python and for popular Python frameworks, such as Django. We categorized the patterns as follows:
Some patterns can belong in more than one category, so please don’t take the choice that we’ve made too serious. If you think a pattern is grossly misplaced in its category,
feel free to create an issue on Github.
Whenever we cite content from another source we tried including the link to the original
article on the bottom of the page. If you should have missed one, please feel free to add it
and make a pull request on Github. Thanks!
This document is licensed under a creative-commons NC license, so you can use the text freely
for non-commercial purposes and adapt it to your needs. The only thing we ask in return is the
inclusion of a link to this page on the top of your website, so that your readers will be able to
find the content in its original form and possibly even contribute to it.
If you think this collection can be improved or extended, please contribute! You can do this by
simply forking our Github project and sending us a pull request once you’re done adding your changes. We will review and merge all pull requests as fast as possible and be happy to include your name on the list of authors of this document.
We would also like to thank all contributors to this book for their effort. A full list of contributors can be found at Github.
If you have any questions concerning this project, please contact one of the maintainers:
Here’s the full index of all anti-patterns in this book.
key in list