Pep 8 Cheat Sheet
Maximum Line Length¶
Limit all lines to a maximum of 79 characters.
There are still many devices around that are limited to 80 characterlines; plus, limiting windows to 80 characters makes it possible tohave several windows side-by-side. The default wrapping on suchdevices disrupts the visual structure of the code, making it moredifficult to understand. Therefore, please limit all lines to amaximum of 79 characters. For flowing long blocks of text (docstringsor comments), limiting the length to 72 characters is recommended.
The preferred way of wrapping long lines is by using Python’s impliedline continuation inside parentheses, brackets and braces. Long linescan be broken over multiple lines by wrapping expressions inparentheses. These should be used in preference to using a backslashfor line continuation.
PEP-8 cheatsheet. GitHub Gist: instantly share code, notes, and snippets. PEP-8 or the Python Enhancement Proposal presents some of the key points that you can use to make your code more organized and readable. As Python creator Guido Van Rossum says: The code is read much more often than it is written. In this post, you'll start to explore PEP-8 with some code examples! You'll cover the following topics. Get code examples like 'pep8' instantly right from your google search results with the Grepper Chrome Extension.
Pep8 Cheat Sheet
Backslashes may still be appropriate at times. For example, long,multiple with
-statements cannot use implicit continuation, sobackslashes are acceptable:
Another such case is with assert
statements.
Python Pep 8 Cheat Sheet
Pep 8 Cheat Sheet Printable
Make sure to indent the continued line appropriately. The preferredplace to break around a binary operator is after the operator, notbefore it. Some examples: