Mitch's Unofficial Python Style Guide

April 25, 2018

TL;DR. Here’s style guide.

PEP 8 does a very good job of being the definitive coding style guide for Python. It details a lot of rules that steer programmers to write code that’s easy to read. It’s a very handy reference to have.

However, as I’m sure you’re aware, it doesn’t cover all the bases. There are often times when you have to go off-script. You’re forced to be creative and to improvise to make sure that the code you write remains readable.

I wrote this style guide in the hopes that it will remove some of the cognitive overhead associated with making code style decisions. The rules are very opinionated, but very easy to follow, and it covers the most common edge cases I’ve encountered.

I don’t claim that this will make your Python code beautiful. But I do believe this will help you get a little bit of your sanity back. Both for your colleague’s sake, and for future-you’s sake.

I put the style guide in its own GitHub repo for easy referencing and updating. Check it out!

🐍

Comments

comments powered by Disqus