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

Ian Bicking ianb at colorstudy.com
Sat Jul 13 18:21:52 EDT 2002


On Sat, 2002-07-13 at 12:34, Roy Smith wrote:
> My fear is that if I could just collapse the body of a compound 
> statement with a single click, it would be too tempting to write huge 
> monolihic functions that go on for hundreds of lines.

I think it would be the other way around -- when you have short
functions, you end up having lots of functions.  To understand what's
going on, you need to look at the larger picture more often -- an
overview of all the functions and their signatures.  This would allow
you to do that more easily.

I'm not sure about the importance of collapsing control structures, as
opposed to just functions and classes -- *that* seems like it might be
abused to hide excessive complexity.  But I usually figure abuse is up
to the individual programmer -- just like you can access private
variables in Python fairly easily, I see no reason to force people to
program right.  They'll pick that up for their own reasons anyway, if
they are smart.

  Ian







More information about the Python-list mailing list