是的,这些指南适用于源代码中的所有行,包括注释。这是因为它们有助于设定编辑器宽度的期望值。如果行长度建议不适用于评论,您仍然需要滚动编辑器窗口才能阅读评论。在
PEP8仍然是一个准则,不是一个严格的法治,你可以随意忽略它。我建议你在任何与更广泛的人合作的地方都坚持这个原则,即使你们都有更大的屏幕。就我个人而言,我喜欢能够并排放置多个编辑器选项卡。在
在Facebook上,我们使用^{}来soft—强制行长度,容差为10%:B950: Line too long. This is a pragmatic equivalent of pycodestyle’s E501: it considers “max-line-length” but only triggers when the value has been exceeded by more than 10%. You will no longer be forced to reformat code due to the closing parenthesis being one character too far to satisfy the linter. At the same time, if you do significantly violate the line length, you will receive a message that states what the actual limit is. This is inspired by Raymond Hettinger’s “Beyond PEP 8” talk and highway patrol not stopping you if you drive < 5mph too fast. Disable E501 to avoid duplicate warnings.
义务免责声明:我为flake8 bugbear做贡献。在