Why "flat is better than nested"?

nn pruebauno at latinmail.com
Wed Oct 27 14:06:17 EDT 2010


On Oct 25, 4:18 pm, Ethan Furman <et... at stoneleaf.us> wrote:
> kj wrote:
> > In <mailman.232.1288020268.2218.python-l... at python.org> Steve Holden <st... at holdenweb.com> writes:
>
> >>> On Oct 25, 5:07 am, kj <no.em... at please.post> wrote:
> >>>> In "The Zen of Python", one of the "maxims" is "flat is better than
> >>>> nested"?  Why?  Can anyone give me a concrete example that illustrates
> >>>> this point?
>
> Two points on the practical side:  most folk only remember a few levels
> deep, so shallow is easier to work with*; and, while premature
> optimization is usually a waste of time, effort, money, hair, etc., each
> level costs another lookup.
>
> >> And everyone taking the Zen too seriously should remember that it was
> >> written by Tim Peters one night during the commercial breaks between
> >> rounds of wrestling on television. So while it can give useful guidance,
> >> it's nether prescriptive nor a bible ...
>
> > Well, it's pretty *enshrined*, wouldn't you say?  After all, it is
> > part of the standard distribution, has an easy-to-remember invocation,
> > etc.  *Someone* must have taken it seriously enough to go through
> > all this bother.  If it is as trivial as you suggest (and for all
> > I know you're absolutely right), then let's knock it off its pedestal
> > once and for all, and remove it from the standard distribution.
>
> The Zen is good humor, and good advice.  An excellent reminder to strive
> for balance in all things...
>
> ~Ethan~
>
> --
> * citation needed, I know

I think the ZoP is just another case of HHOS:
 http://sunsite.ualberta.ca/jargon/html/H/ha-ha-only-serious.html



More information about the Python-list mailing list