Skip to content

Instantly share code, notes, and snippets.

@7yl4r
Last active December 24, 2015 06:19
Show Gist options
  • Save 7yl4r/6756413 to your computer and use it in GitHub Desktop.
Save 7yl4r/6756413 to your computer and use it in GitHub Desktop.
My personal deviations from PEP8

The following is a list of ways that I will typically deviate from PEP8 convention in my python codebases. These are just my personal preferences which you may want to be aware of if you are looking to collaborate with me. That being said, if I am doing something that drives you nuts please let me know. These are not hard rules about how my code must be, and I will gladly change if given a good reason to.

tabs, not spaces!

This is the big one. Rather than 4 spaces to signal an indent, I like to use 1 tab. It reduces keystrokes and allows for me to adjust the tab size in my text editor so I can view it however I want.

An additional convention that come along with this use: tabs for nesting; spaces for alignment. I.e., additional whitespace is added with spaces. If you want something to line up horizontally, you do it with spaces so that it will align no matter what size I have tab set to in my text editor.

mixedCase naming

similar to CapWords, StudlyCaps, or CamelCase -- so named because of the bumpy look of its letters), but with initial lowercase character.

I use this throughout in order to minimize keystrokes needed.

single character names are avoided

Single character names are difficult to ctrl+f for in simple text editors so I try to come up with something more descriptive unless I am feeling completely devoid of imagination.

horizontal alignment of assignments is fine

PEP8 says this:

x             = 1
y             = 2
long_variable = 3

is not okay. I disagree and sometimes like to align related variable assignments.

Inline comments are fine

PEP8 discourages inline comments like:

x = x + 1                 # Increment x

While I agree that this particular comment is unneccesary, comments should be encouraged as much as possible and should be allowed wherever they seem to fit best.

no tuple comments

I don't know why, they just make me cringe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment