PEP8 79 char max

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Sep 5 23:40:46 EDT 2013


On Thu, 05 Sep 2013 15:21:28 -0700, Metallicow wrote:

> Well as for my opinion, it is more closer to the truth than others
> because... Experience:
> 1. I know Python and have read the PEP8. 2. I have knowledge of/worked
> with the Printing Trades. 3. Grandfather owned/operated own Printshop
> for 40+yrs. Which I also worked in at one point.

Thanks for the comments, and welcome, but I really don't have a clue what 
the relevance of most of them are.


> If you are still using equipment that requires 79, then chances are you
> have/will already gone out of business or are keeping/using said
> equipment for nostalgic purposes.

The point is not that there is *equipment* that requires 79 characters 
per line, but that *reading text* is better with a maximum line length 
closer to 79 characters than (say) 140 characters. I've just randomly 
picked up a magazine (less than 50 characters per line) and two books (60 
and 82 characters per line respectively).

The exact max line length picked is not, in and of itself, critical. PEP 
8 could have picked 60 characters, or 72, or 77, or 82. 79 characters 
(plus newline) happens to be a better choice than (say) 77 or 82 for 
historical reasons: some *old* computer equipment was limited to 79 
characters (plus newline), and consequently some *new* computer software 
expects the same convention to be held.

In a sense, it's a bit like the old urban legend about the width of the 
Space Shuttle booster rockets being determined by the width of ancient 
Roman chariots.

http://www.snopes.com/history/american/gauge.asp

While the precise details are wrong, the general claim is more or less 
true for boring and unremarkable reasons.


> As far as math goes. 10 is a nice round number. So multiples of 10 are
> prefer. 80 being my personal choice for editing.

That gives you 80 visible characters plus newline = 81 characters in 
total. Quick, what's 81/7?

> Zen says: Simple is better than complex. Use a round number. Integer
> math is easier than float math for the majority of the population. Time
> yourself, not the interpreter with these three questions: In the face of
> ambiguity, refuse the temptation to guess. If it helps get out the old
> school pen and paper. Question1: 80/8
> Question2: 79/8

I don't see the point of this. Why divide by 8? What is this supposed to 
demonstrate?

Also, you're tossing around koans from a Zen that are irrelevant. 79 or 
80, both are equally simple. Where is the ambiguity? The reader might be 
forgiven for thinking you're trying to dazzle them and pull the wool over 
their eyes by tossing out references to the Zen that sound good but have 
no relevance to the question being discussed.


> Question3: How many chars does you calculator(real or virtual) support?

Seven. Are you suggesting that we should limit our code to a maximum of 
seven characters per line? If not, I don't see the point of your question.


> Zen says: Special cases aren't special enough to break the rules. PEP8
> isn't a rule. Rules are defined by the equipment/device developers.

PEP 8 certainly is a collection of rules. They are mandatory for new code 
added to the standard library, and optional but recommended for third 
party libraries.


> Ask yourself... How often do you actually use these 79char devices?

My brain is better at reading lines with maximum line length of 79 
characters than 140 characters. How often do I use my brain? At least 
once a day.


[...]
> Zen says:
> Although practicality beats purity.
> Errors should never pass silently.
> Unless explicitly silenced.

And yet, a bird in the hand saves nine, and the early bird bells the cat.


> PEP8 would have been better to define various numbers for realworld
> types of equipment/devices based on average general type of
> equipment/device specs.

No it would not. That would be silly.


> Closing Zen:
> If the implementation is hard to explain, it's a bad idea. If the
> implementation is easy to explain, it may be a good idea.

The implementation is easy to explain: stop typing before you reach 79 
characters, and start a new line of code.


> Yep, that's my nuts and bolts on the issue. Walk into you local
> Printshop and ask them about this stuff. Then on your way out the door,
> ask for a business card and see how many chars are on that also. Beware:
> You might actually learn something about advertising while you are there
> also. :)

I don't need to ask them for a business card, since I have a nice 
collection of them. Most of them have < 40 characters per line. A few 
have < 60 characters on the longest line. None of them come even close to 
79 characters per line.

What's your point? That we should limit ourselves to code that fits on a 
business card?



-- 
Steven



More information about the Python-list mailing list