How Do I Keep Python Code Under 80 Chars Without Making It Ugly?

后端 未结 7 487
醉梦人生
醉梦人生 2021-01-31 14:27

This is a question that keeps recurring in all of my programming, python and otherwise. I really like to keep my code under 80 chars if at all possible/not horribly ugly. In a l

相关标签:
7条回答
  • 2021-01-31 15:06

    The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash for line continuation. Make sure to indent the continued line appropriately. The preferred place to break around a binary operator is after the operator, not before it.

    PEP 8 Style Guide for Python Code (follow link for examples).

    0 讨论(0)
提交回复
热议问题