| Store | Cart

What does "Sparse is better than dense" mean? (Python Zen)

From: James J. Besemer <j...@cascade-sys.com>
Fri, 12 Jul 2002 23:01:57 -0700
Donn Cave wrote:

> Quoth eddie at holyrood.ed.ac.uk (Eddie Corns):> ...> | Basically, when you layout code you need to think about how to convey to the> | reader what's going on.  In constructions like the above I believe it's much> | easier to see that it's only ever looking at the beginning of the line and the> | table like structure makes it easy to map what it finds to what gets done.>> Don't try to come up with nifty ways to convey to the reader what's> going on.  Read the coding standards in PEP 8, and follow them to> the letter.  You can't do better.

"...to the letter."  This strikes me as a "foolish consistency."

I think the standard is good overall but what makes it best is it acknowledges up
front that there's some room for personal judgment and common sense.  Among adults I
expect we all can accommodate a little flexibility in following these rules.  So to
some extent, I regard interpreting it "to the letter" to be inconsistent with how
the PEP is written.

My particular problem is that some of the express rules about horizontal white space
actually hinder readability.  As Mr. Corns points out, some sections of code are
inherently tabular and I agree that presenting them in tabular format is the
clearest way to format the code.  You simply cannot argue that the extra white space
obscures the meaning because it obviously adds clarity.  You could argue that it
doesn't help a lot or that it IS a bit more tedious to maintain.  (Of course part of
the maintenance problem is a direct consequence of Fearless Leader's treasonous
reversal of position on horizontal tabs.)  But from a readability standpoint, it is
a superior (and harmless) deviation from the standard.

I'll concede that most deviations from the standards do hinder readability.
Overall, it's a pretty good standard.  But it's not perfect and horizontal white
space is one place where, BDFL's personal biases notwithstanding, the standard is
overly specific.  I guess the trouble it that the nature of the language
intrinsically avoids so many of the important battles that we're left to quibble
about secondary and tertiary matters.

Of course, I come from a far away land, where Python is but one tool among many on
the work bench, rather than some kind of a religion.

Regards

--jb

--
James J. Besemer  503-280-0838 voice
http://cascade-sys.com  503-280-0375 fax
mailto:jb at cascade-sys.com

Recent Messages in this Thread
Alex Martelli Jul 11, 2002 02:28 pm
Martijn Faassen Jul 11, 2002 04:54 pm
Alex Martelli Jul 11, 2002 08:28 pm
Donn Cave Jul 11, 2002 09:17 pm
James J. Besemer Jul 12, 2002 05:43 am
Eddie Corns Jul 12, 2002 02:40 pm
Donn Cave Jul 12, 2002 05:18 pm
James J. Besemer Jul 13, 2002 06:01 am
Donn Cave Jul 13, 2002 07:26 am
James J. Besemer Jul 13, 2002 10:34 am
Michael Hudson Jul 15, 2002 02:47 pm
Aahz Jul 13, 2002 03:28 pm
Alex Martelli Jul 12, 2002 07:33 am
James J. Besemer Jul 12, 2002 08:33 am
Messages in this thread