[Python-ideas] PEP 8 update on line length

David Mertz mertz at gnosis.cx
Mon Feb 25 00:47:31 EST 2019


As a human, and one who reads and writes code even, I know that MY ability
to understands the meaning of a line of code starts to plummet when it
reaches about 65-70 characters in length.

Yes, of course there are some "it depends" caveats that make some lines
easier and some harder. But an 80 characters "limit" is an excellent rule
of thumb, as long as most coders usually "err" on the short side.

My brain is a lot like those of people whom typesetters have typeset for
for hundred of years, and whom scribes have written for for thousands. It's
easy to be sophistical and discover that code is so very much different
that roles of intelligibility don't apply. It's not though, and they do
still.

Or maybe everyone else in the thread is simply smarter and better able to
handle complexity than I am. More power to you, but that definitely doesn't
feel like "computer programming for everyone."

If you want to write 100 or 120 characters lines, Python won't complain,
but you've walled off your code from me as a potential reader of it.

On Mon, Feb 25, 2019, 12:25 AM Raymond Hettinger <
raymond.hettinger at gmail.com> wrote:

>
>
> > On Feb 22, 2019, at 1:10 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>
> wrote:
>
> >> “Typesetters hundreds of years ago used less than 80 chars per line, so
> that’s what we should do for Python code now” is a pretty weak argument.
> >
> > But that's not the entire argument -- the point it is that typesetters
> > had the goal of making lines of text readable, which is similar (if not
> > quite the same) as the goal of making lines of program code readable.
> > It's a lot closer than, for example, the goal of fitting in an
> > accountant's spreadsheet.
>
>
> The issue with reference to typesetter rules is that they were targeted at
> blocks of prose rather than heavily nested hanging indents with non-trivial
> string literals or a dotted attribute notation.  Typesetters were also
> dealing with fixed page widths and need to leave gutter space for binding.
>
> The "rules" aren't comparable at all.
>
>
> > I would say it the other way around. Once you've reduced the complexity
> > of a line to something a human can handle, *most* of the time 80 chars
> > is enough.
>
> That would make sense if we started at column 0; however, if you have your
> prefix your thoughts with something like
>
> '''
> class TestRemote(unittest.TestCase):
>     def test_heartbeat(self):
>         ...
>         self.assertIsInstance(...
> '''
>
> then the meant of the part "a human can handle" starts at column 30.  Then
> if you need good variable names and/or have to module.function prefixes,
> there is sometimes little to left to work with.
>
>
> Raymond
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190225/6ab3fb0f/attachment.html>


More information about the Python-ideas mailing list