[Python-ideas] PEP 8 update on line length
Raymond Hettinger
raymond.hettinger at gmail.com
Mon Feb 25 00:21:42 EST 2019
> 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
More information about the Python-ideas
mailing list