Style Guide
Limit all lines to a maximum of 79 characters.
I used to follow this guide and set the default value to 79 characters in Lint.
However, the readability was sometimes compromised to comply with this, so I decided to reread the guide and tune the setting values.
Some teams strongly prefer a longer line length. For code maintained exclusively or primarily by a team that can reach agreement on this issue, it is okay to increase the line length limit up to 99 characters, provided that comments and docstrings are still wrapped at 72 characters.
The rationale for the 79 characters is described as follows.
Limiting the required editor window width makes it possible to have several files open side by side, and works well when using code review tools that present the two versions in adjacent columns.
The default wrapping in most tools disrupts the visual structure of the code, making it more difficult to understand. The limits are chosen to avoid wrapping in editors with the window width set to 80, even if the tool places a marker glyph in the final column when wrapping lines. Some web based tools may not offer dynamic line wrapping at all.
I see.
Also, in A Foolish Consistency is the Hobgoblin of Little Minds there is a section that says
However, know when to be inconsistent -- sometimes style guide recommendations just aren't applicable. When in doubt, use your best judgment. Look at other examples and decide what looks best. And don't hesitate to ask!
Note
IDE defaults
VisualStudioCode and PyCharm defaulted to 120 characters per line.
Other Languages
Characters per line - Wikipedia has a good summary.
There are many languages with 80 characters.
Interestingly, they seem to be derived from typewriters and punch cards.
How long is my Maximum Line Length for PEP 8?
So, I changed the Maximum Line Length to 90 for the time being because, in our team's standard editors, about 90 characters can be displayed in the one tree tab + two editor tabs.
It's been a couple of months now, and I'm glad I changed it.
I'm thinking of changing it to 99 characters after seeing how it goes.
Top comments (1)
When I was young, I loved tweaking all my tools.
I gave up: I found I have learned to live with the defaults offered by my tools. On windows, my programs are no longer installed under
C:\myprograms
, my backgrounds are off-the-shelf. And my line length is 79.This gives me peace: I adapt to the environment provided and focus on solving real problems.
Accepting the 79-character limit saves me time, since most tools (black, pylint, ...) use the PEP-8 value out of the box.
My colleagues, however, can't yet live with that. So my professional line length is 120. This saves me a lot of complaints.