Index ¦ Archives ¦ Atom

Moving beyond PEP 8

I recently watched Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - from PyCon 2015. It was an ammazing talk and I'd higly reccomend it to anyone wanting to write readable Python code.

One of the first things he tackled was the 79 character line limit. That's something that has always annoyed me, as I personally like long and descriptive variable names and if your already tabbed in four or eight spaces it dosn't always leave a lot of space for your code. I know I've been guilty of writing worse and less readable code just to make my code squeeze into the space available. Really if your code is PEP 8 compliant but harder to read then you have missed the point of PEP 8.

I feel very strongly about descriptive variable names, I've worked with software that was originaly written for Gupta SQL Base in 1992 when it didn't support column names longer than 18 character. This lead to some great names like PRJ_CON_RET_DAT, you might be able to work out what is but a variable like project_contract_returned_date is so much easier to understand. Some people have said long descriptive variable are hard to type, but I think people should be using an editor with autocomplete.

Raymond also tackes a few other ways to make your code more pythonic.

Creative Commons License
Content on this site is licensed under a Creative Commons Attribution 4.0 International License.
Built using Pelican. Based on a theme by Giulio Fidente on github.