3 ms·
Originally PEP 8 had 79 characters. Now that was a weird choice so most companies went with 80 instead, including Facebook. You want a low-ish limit because it
by ambivalence 8y ago
Originally PEP 8 had 79 characters. Now that was a weird choice so most companies went with 80 instead, including Facebook. You want a low-ish limit because it makes it possible to fit two files side by side on a typical screen resolution. Even if you don't edit like that, you look at diffs like that. More importantly, a low column limit is helpful to disabled engineers who don't have to navigate horizontally so much.
So we used 80. I always felt bad when the linter stopped people from pushing impactful changes because they went over the limit by two characters. So two years ago I set up a "highway speed limit" style warning in flake8 (code B950 in PyCQA/flake8-bugbear). What it does is it keeps your limit intact (for example "80") but doesn't trigger unless you went over by more than 10%. So the limit happens to be 88.
When I was working on Black, I was faced with a dilemma. Should the formatter stick to 80 or be able to "go over" a bit, too, as we would let humans do. I felt like the latter made more sense as the resulting code looks nicer (fewer occasions to break a single line into three or more). Then I remembered Raymond's talk "Beyond PEP8" where he mentions that experience shows "90-ish" is the wisest choice. So I went with it.
- bpicolo 8y ago> More importantly, a low column limit is helpful to disabled engineers who don't have to navigate horizontally so much. I saw that you mentioned that - where have you seen a study that claims 100 is the cutoff? Would be interested in seeing that.
- ambivalence 8y agoI don't have a formal study, just conversations with several legally blind engineers I work with.
- B1FF_PSUVM 8y ago> Originally PEP 8 had 79 characters. Now that was a weird choice so most companies went with 80 instead Probably thinking of one of these: - backslash continuations - terminals/etc that counted newlines - off by one errors
- Izkata 8y agoAlso possibly a terminal text editor - the cursor sits on the column where the next character would be input (such as vim's insert mode). So with 79 character lines, the cursor is sitting at 80 while waiting for the next input. If your screen is larger than that it's no big deal, but if your screen is 80 columns and the cursor was at column 81, it would wrap to the next line without actually being a newline.