On Oct 25, 2:56 pm, Robin Becker <ro...@reportlab.com> wrote: > 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 > is wrong!". > > The nested nature makes the semantics quite hard. The same will be true of > nested tuple/list and similar programming structures.
I agree in the case of a suped-up hierachical record structure that encourages code like my_far = the_record.something.something_else.foo[2].keep_going.bar.baz() A tree of homogeneous nodes that one walks or recurses into (e.g. a b- tree or r-tree) is a case where I would ignore this maxim -- http://mail.python.org/mailman/listinfo/python-list