Why "flat is better than nested"?

andrewpate08 at gmail.com andrewpate08 at gmail.com
Fri Dec 22 09:48:16 EST 2017


On Monday, October 25, 2010 at 11:07:42 AM UTC+1, kj 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?
> 
> TIA!
> 
> ~kj
> 
> PS: My question should not be construed as a defense for "nested".
> I have no particular preference for either flat or nested; it all
> depends on the situation; I would have asked the same question if
> the maxim had been "nested is better than flat".

I think there is a point where flat stops working. One of the products I work on has a 40-50 field datastructure - it is hard to work with and find the appropriate fields in. So I would say structured is better than flat but simple is better than to structured.



More information about the Python-list mailing list