PEP 8 – Style Guide for Python Code (Introduction; A Foolish Consistency is the Hobgoblin of Little Minds) PEP 8: A Foolish Consistency Guido van Rossum, Barry Warsaw and Alyssa Coghlan Guido van Rossum, Barry Warsaw, Alyssa Coghlan (van Rossum b. 1956) 2001, revised since Cold Library · Open Stacks · S-007012 · https://coldlibrary.com/s/007012 Rights: Dedicated to the public domain: ‘This document has been placed in the public domain.’ Guidance, not legal advice. Source: Python Enhancement Proposals, https://peps.python.org/pep-0008/ (retrieved 2026-10-11) Generated 2026-10-14 from https://coldlibrary.com/en/open-stacks/pep-8-a-foolish-consistency ---- Introduction This document gives coding conventions for the Python code comprising the standard library in the main Python distribution. Please see the companion informational PEP describing style guidelines for the C code in the C implementation of Python. This document and PEP 257 (Docstring Conventions) were adapted from Guido’s original Python Style Guide essay, with some additions from Barry’s style guide. This style guide evolves over time as additional conventions are identified and past conventions are rendered obsolete by changes in the language itself. Many projects have their own coding style guidelines. In the event of any conflicts, such project-specific guides take precedence for that project. A Foolish Consistency is the Hobgoblin of Little Minds One of Guido’s key insights is that code is read much more often than it is written. The guidelines provided here are intended to improve the readability of code and make it consistent across the wide spectrum of Python code. As PEP 20 says, “Readability counts”. A style guide is about consistency. Consistency with this style guide is important. Consistency within a project is more important. Consistency within one module or function is the most important. However, know when to be inconsistent – sometimes style guide recommendations just aren’t applicable. When in doubt, use your best judgment. Look at other examples and decide what looks best. And don’t hesitate to ask! In particular: do not break backwards compatibility just to comply with this PEP! Some other good reasons to ignore a particular guideline: 1. When applying the guideline would make the code less readable, even for someone who is used to reading code that follows this PEP. 2. To be consistent with surrounding code that also breaks it (maybe for historic reasons) – although this is also an opportunity to clean up someone else’s mess (in true XP style). 3. Because the code in question predates the introduction of the guideline and there is no other reason to be modifying that code. 4. When the code needs to remain compatible with older versions of Python that don’t support the feature recommended by the style guide.