Multiple with-statements could not use implicit continuationīefore Python 3.10, so backslashes were acceptable for that case: These should be used in preference to using a backslashīackslashes may still be appropriate at times. Long linesĬan be broken over multiple lines by wrapping expressions in Line continuation inside parentheses, brackets and braces. The preferred way of wrapping long lines is by using Python’s implied Lines to 79 characters (and docstrings/comments to 72). The Python standard library is conservative and requires limiting Provided that comments and docstrings are still wrapped at 72 Issue, it is okay to increase the line length limit up to 99 characters, 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
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |