[Python-ideas] 80 character line width vs. something wider

Ben Finney ben+python at benfinney.id.au
Thu May 21 12:01:13 CEST 2009


Jeremiah Dodds <jeremiah.dodds at gmail.com>
writes:

> hmm, the 80-character convention does not stop me from unconsciously
> writing really complex list comprehensions, I just write them like so:
> 
> def foo(f, a, b, c):
>     return [[((f(x,y) * i, i) if i % 2 else 0)
>                 for i, x in enumerate(a)
>                 if f(y, x) == a + x]
>               for y in [c(z) for z in range(a, a*b+c, c)]]
> 
> not that that's really any better.

On the contrary, I find that *much* easier to grasp than the same
statement on a single line. You have been required, by choosing to
follow the 80-column limit, to choose points at which to break the line;
and have responded by breaking it up into conceptually discrete chunks
and indented to suggest the structure.

This example is, for me, a very convincing (anecdotal) demonstration of
why an 80-column limit is a good constraint to follow.

> But yeah, this is all anectodal evidence and personal taste, as
> Raymond points out.

Yet it's also more than that; to call it “personal taste” is to imply
that it's nothing more than aesthetics. If that's all it were, I'd care
far less for changes in convention.

I consider it rather more importantly a matter of software ergonomics,
which should therefore not be changed unless there's good supporting
evidence that the proposed change results in improvement.

-- 
 \         “A cynic is a man who knows the price of everything and the |
  `\                                   value of nothing.” —Oscar Wilde |
_o__)                                                                  |
Ben Finney




More information about the Python-ideas mailing list