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

Peter Hansen peter at engcorp.com
Thu Jul 11 08:24:28 EDT 2002


Miki Tebeka wrote:
> 
> Hello All,
> 
> Although it's in the Humor section I take the Python Zen
> (http://www.python.org/doc/Humor.html#zen) quite seriously.
> However I can understand what does “Sparse is better than
> dense” means.

It (means don't write):
  your-code=like+this; because(no,one)
  will,be,able=to-read(what,you,are,writing+without-effort)

Instead, use lots of white space.

Put empty lines between blocks of unrelated code within functions,
put spaces around operators much of the time (except for the "="
in default/named arguments like the above).

Put two lines between method or function definitions.  

Let the air into the code so it can breathe.  Code that is too
dense starves for air and withers and dies.

At least, that's my interpretation. :)

-Peter



More information about the Python-list mailing list