How long is your Maximum Line Length for PEP 8?

Style Guide

PEP 8 Maximum Line Length

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, …


This content originally appeared on DEV Community and was authored by Shuichi

Style Guide

PEP 8 Maximum Line Length

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.


This content originally appeared on DEV Community and was authored by Shuichi


Print Share Comment Cite Upload Translate Updates
APA

Shuichi | Sciencx (2021-09-06T01:52:33+00:00) How long is your Maximum Line Length for PEP 8?. Retrieved from https://www.scien.cx/2021/09/06/how-long-is-your-maximum-line-length-for-pep-8/

MLA
" » How long is your Maximum Line Length for PEP 8?." Shuichi | Sciencx - Monday September 6, 2021, https://www.scien.cx/2021/09/06/how-long-is-your-maximum-line-length-for-pep-8/
HARVARD
Shuichi | Sciencx Monday September 6, 2021 » How long is your Maximum Line Length for PEP 8?., viewed ,<https://www.scien.cx/2021/09/06/how-long-is-your-maximum-line-length-for-pep-8/>
VANCOUVER
Shuichi | Sciencx - » How long is your Maximum Line Length for PEP 8?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/06/how-long-is-your-maximum-line-length-for-pep-8/
CHICAGO
" » How long is your Maximum Line Length for PEP 8?." Shuichi | Sciencx - Accessed . https://www.scien.cx/2021/09/06/how-long-is-your-maximum-line-length-for-pep-8/
IEEE
" » How long is your Maximum Line Length for PEP 8?." Shuichi | Sciencx [Online]. Available: https://www.scien.cx/2021/09/06/how-long-is-your-maximum-line-length-for-pep-8/. [Accessed: ]
rf:citation
» How long is your Maximum Line Length for PEP 8? | Shuichi | Sciencx | https://www.scien.cx/2021/09/06/how-long-is-your-maximum-line-length-for-pep-8/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.