PEP 8 : Maximum line Length :
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Wed May 14 23:28:17 EDT 2014
On Wed, 14 May 2014 19:36:13 -0700, Rustom Mody wrote:
> And there are (semi)hard technological limits like if you post code
> longer 65 chars out here it will fold at random unforeseen points. These
> limits get irrelevant as the technology changes.
The technological limits may become irrelevant, but the human limits do
not. While there are no *hard* limits to readability, both excessively
long and excessively short lines are hard to read. Comprehension and
reading speed suffers.
> If any of these has any relation with the magic number '79' I'd be
> curious to know.
79 is one short of 80, which gives you a margin of error of 1: off-by-one
errors won't matter if you aim for 79 characters but miscalculate by one.
People repeatedly state that 80 is the old, obsolete hard limit for
ancient terminal systems, but the reason terminals standardised on 80
rather than 70 or 90 (or for that matter 300 or 30) is at least in part
-- and I maintain a big part -- because of human reading. 60 to 90
characters per line is a comfortable range for human readability, which
makes 80 a reasonable compromise that tends towards the upper end but
without pushing hard up against it.
Keeping the monitor size and character size fixed, it's easy to show
*fewer* characters per line if you choose a standard towards the upper
end, if you so choose, but impossible to squeeze in more if you choose a
standard at the lower end.
Just because the monitor (or the standard) *allows* up to 79 characters
per line doesn't make it a good idea to regularly use that many. In my
experience, given two or three indent levels, reasonably descriptive
variable names, decently expressive expressions, I find that 60-70
characters is *typically* enough horizontal space for the average line of
code. Long lines are often (not always) a sign that you're doing too much
in one line. This isn't Perl, and newlines are a renewable resource.
> Until then may we relegate '79' to quaint historical curiosities like:
> Continuation in 6th column, Comment is a C in 1st column, 7-72 for code
> (ALONG WITH ALL CAPS CODE)?
Nope. Because the main driving force for 79 characters is not technology
but human reading.
--
Steven D'Aprano
http://import-that.dreamwidth.org/
More information about the Python-list
mailing list