[Python-ideas] PEP 8 update on line length
Antoine Pitrou
solipsis at pitrou.net
Fri Feb 22 04:44:10 EST 2019
On Thu, 21 Feb 2019 11:59:56 -0800
Raymond Hettinger
<raymond.hettinger at gmail.com> wrote:
>
> PEP 8 is mostly about readability. However, the line length limit often seems to cause less readable code.
There are well-known typography rules around line length and
readability, both on screen and in print. See e.g.:
https://baymard.com/blog/line-length-readability
It's not straight-forward how to apply these for code, because it is
typically indented, with varying levels of indentation (should the
indentation count towards character line length when making up a
rule of thumb for readability?). However, there is a commonly held idea
- with centuries of experience backing it - that overly long lines makes
text or code less readable (look at your typical newspaper or magazine:
it splits pages of text into a number of columns so as to limit line
width). And "overly long" starts rather early, around 50-80 characters
for non-indented text according to most typographers.
For code, a 80 character limit is common, as are other limits such as 90
and 100. In any case, each project can customize their pep8 / flake8
settings easily. PEP 8 doesn't aim to be an inflexible standard (we
don't even apply it mechanically in the stdlib).
Regards
Antoine.
More information about the Python-ideas
mailing list