[Python-ideas] PEP 8 update on line length
Chris Angelico
rosuav at gmail.com
Wed Feb 20 14:57:20 EST 2019
On Thu, Feb 21, 2019 at 6:48 AM Jonathan Fine <jfine2358 at gmail.com> wrote:
> Here's a suggestion, at least for people projects that use black.py
> (such as Samuel's). It is to use black.py with a line-length of say 80
> characters for code that is saved in version control. And when editing
> code, use whatever line-length that happens to suit the tools you are
> using.
>
> Indeed, like a word-processor, one could use black.py to 'line-wrap'
> the Python code to what is the current width of the editor window.
>From my experience (granted, I work heavily with students, so maybe
it's different if everyone involved in the project has 5+ or 10+ years
coding), autoformatters are a blight. They take a simple, easy-to-find
missed parenthesis, and completely obscure it by reindenting the code
until it finds something unrelated that seems to close it. The
indentation in the code of even a novice programmer is valuable
information about *programmer intent*, and throwing that away
automatically as part of checking in code (or, worse, every time you
save the file) is a bad idea. Easy bugs become hard.
Of course, if you assume that everything in your code is perfect, then
by all means, reformat it however you like. If you're 100% confident
that nobody writes any buggy code, then the formatting doesn't matter,
and you can display it in whichever way looks prettiest. But if you
appreciate ways of discovering bugs more easily, preserve everything
that represents the programmer's intention.
ChrisA
More information about the Python-ideas
mailing list