For code maintainedĮxclusively or primarily by a team that can reach agreement on this Some teams strongly prefer a longer line length. Some web based tools may not offer dynamic line wrapping at all. If the tool places a marker glyph in the final column when wrapping The limits are chosen toĪvoid wrapping in editors with the window width set to 80, even The default wrapping in most tools disrupts the visual structure of theĬode, making it more difficult to understand. Review tools that present the two versions in adjacent columns. Several files open side by side, and works well when using code Limiting the required editor window width makes it possible to have (docstrings or comments), the line length should be limited to 72 Limit all lines to a maximum of 79 characters.įor flowing long blocks of text with fewer structural restrictions Python disallows mixing tabs and spaces for indentation. Tabs should be used solely to remain consistent with code that is Spaces are the preferred indentation method. My_list = result = some_function_that_takes_arguments ( 'a', 'b', 'c', 'd', 'e', 'f', ) Tabs or Spaces? Indent the following should be considered there should be noĪrguments on the first line and further indentation should be used toĬlearly distinguish itself as a continuation line: Using Python’s implicit line joining inside parentheses, brackets andīraces, or using a hanging indent. Python that don’t support the feature recommended by the style guide.Ĭontinuation lines should align wrapped elements either vertically
The readability of code and make it consistent across the wide The guidelines provided here are intended to improve One of Guido’s key insights is that code is read much more often than A Foolish Consistency is the Hobgoblin of Little Minds In the event of anyĬonflicts, such project-specific guides take precedence for that project. Many projects have their own coding style guidelines. Identified and past conventions are rendered obsolete by changes in This style guide evolves over time as additional conventions are Guido’s original Python Style Guide essay, with some additions from This document and PEP 257 (Docstring Conventions) were adapted from
Please see theĬompanion informational PEP describing style guidelines for the C code The standard library in the main Python distribution. This document gives coding conventions for the Python code comprising