Coding style matters, the importance of PEP8

Bob Belderbos
Feb 19, 2017 · 1 min read

There should be one — and preferably only one — obvious way to do it.

I am the first one to have broken PEP8 compliance when I was learning the language, you can only take up so much. With more practice comes more skill, it’s a gradual process. However the more you stick to the guidelines the more readable your code is.

What concerns me though is that I am still seeing authors of educational material breaking the styleguide pretty badly.

I think everybody writing code in Python should become familiar with PEP8 and use its guidelines rather sooner than later.

More readable code saves brain cycles and leads to more maintainable code (= fewer bug). Also sharing a common coding style makes it easier to collaborate with others in the Python community.

Of course there can be exceptions to the rule, PEP8 states: “do not break backwards compatibility just to comply with this PEP!” — you don’t want to break your code base just to comply with the guidelines, pragmatism is key.

Raymond Hettinger did a great talk on this: Beyond PEP 8

We have a 5 min guide to PEP8 article on our PyBites blog. It includes links to tools to make this easier. Apart from that, just read the the full style guide at least once.

Happy coding!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store