Luke Lee

Software Engineer

Web + Desktop + Science

Fork me on Github

Beyond PEP 8

Beyond PEP 8 -- Best practices for beautiful intelligible code is another great talk by the Python-famous Raymond Hettinger. Each year at Pycon US Mr. Hettinger manages to teach a roomful of experts and novices something useful. This is an incredibly difficult thing to do. His most recent Pycon talk about PEP8 provides key insights for beginners and seasoned veterans alike as he focuses on the practice of 'PEP8-ing' code.

I'm sure you're familiar with this term if you've worked a Python application with more than 1 developer in the past. Typically a newcomer on the project will try to get involved and go around cleaning up whitespace, line lengths, and other miscellaneous things that tools like Pylint complain about. As Mr. Hettinger points out, this can be useful. It can also contribute to the superficial score Pylint gives your code. Unfortunately, these PEP8-ing sessions can lead to subtle bugs.

So, Mr. Hettinger's talk is not about this kind of PEP8-ing. Instead he focuses on how to modify and simplify existing code to conform to more Pythonic standards. These standards aren't represented in PEP8, but they are arguably more important to code quality. I don't want to give anything away so you'll have to watch the talk. Do yourself a favor and spend 50 minutes today watching Mr. Hettinger walk you through transforming a Java API into a clean Python API. You'll probably be surprised at how useful his tips are for your own code.

Published: 08-10-2015 09:34:30