[Python-Dev] PEP 8 modernisation

Nick Coghlan ncoghlan at gmail.com
Thu Aug 1 14:44:12 CEST 2013

With feedback from Guido, Barry, Raymond and others, I have updated
PEP 8 to better describe our current development practices. It started
as an update to describe the different between public and internal
interfaces and to advise against using wildcard imports, but became
substantially more :)

For those that want full details, the relevant commit and tracker
issue are here:


If you're responsible for a coding standard that includes PEP 8 by
reference, you probably want to take a look at these :)

For everyone else, here are the highlights:

1. Made it clear this is a living document (using the approach of
creating a tracker issue for major updates and adding a new footnote
referencing that issue)
2. Added more specific points to the "foolish consistency" section to
help out those folks resisting pointless PEP 8 compliance for code
that predates the existence of the PEP's recommendations.
3. Stopped being wishy-washy about tabs vs spaces. Use spaces :)
4. Lines up to 99 characters are now permitted (but 79 is still the
preferred limit)
5. The encodings section is now emphatically in favour of UTF-8
(latin-1 is no longer even mentioned)
6. While absolute imports are still favoured, explicit relative
imports are deemed acceptable
7. Wildcard imports are strongly discouraged for most cases (with
dynamic republishing the only acceptable use case, since PEP 8 doesn't
apply at all for the interactive prompt)
8. New section explaining the distinction between public and internal
interfaces (and how to tell which is which)
9. Explicit guideline not to assign lambdas to names (use def, that's
what it's for)
10. Various tweaks to the exception raising and handling guidelines
11. Explicit recommendation to use a decorator in conjunction with
annotations in third party experiments


P.S. It's possible this should also be published through
python-announce and other channels...

Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list