Why "flat is better than nested"?
robin at reportlab.com
Mon Oct 25 15:56:23 CEST 2010
On 25/10/2010 11:07, 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?
I believe that the following illustrates the nesting issue (I think this is from
somewhere in Chomsky)
The rat ate the corn.
The rat that the cat killed ate the corn.
The rat that the cat that the dog chased killed ate the corn.
I believe this is called central embedding.
There's also the old schoolboy saying "I know that that that that that boy said
The nested nature makes the semantics quite hard. The same will be true of
nested tuple/list and similar programming structures.
More information about the Python-list