I ❤️ PEP8

(null)

Two weeks ago, I attended DjangoCon 2016 in Philadelphia. It was a great conference, and I’ll have more to say about that in a future post, but this post isn’t about DjangoCon.

Ben Lopatin gave a talk called “Working with legacy Django projects.” This post isn’t about that talk, either, though it was an excellent talk.

When he gave the talk, Ben was wearing a t-shirt that had “I ❤️ PEP8” on it. ‘That is a great shirt,’ I thought. ‘I have to have one,’ I continued. As you can see in the photo above, I now have one. It wasn’t really until after it arrived that I gave much thought as to why I liked it so much.

PEP8 is a style guide for writing Python code. We follow PEP8 in the GreeneLab for all of our Python code. I suppose my first impulse to buy the shirt came from being a programming nerd who wanted to proudly fly his freak flag, and nothing could be more obscure and wonky than declaring one’s love for a programming style guide on a t-shirt. That is reason enough to get the shirt, but that wasn’t really it.

If a t-shirt declares your membership on a team, then what is Team PEP8 all about? Programmers repeatedly tackle the challenge of getting the computer to understand what it should do in response to our commands. That is the nature of programming. But we have syntax for that. A style guide puts additional constraints on what you write in your programs. Why make it harder than it already is to get the computer to do the right thing? Because getting computers to follow along is the easy part. The real challenge of programming is writing code that not only gets the computer to jump through the right hoops in the right order, but does so in a clear and uncomplicated way that another programmer can also understand. That is what a style guide is for. Write readable code, make better software. That is why I ❤️ PEP8. Go, team!

Oh, yeah. If you want, you can join the team too. It takes more than a t-shirt, though that might help. It takes more than a style guide, too. You have to work on the craft of writing readable code. Are you up for that challenge?