Why "flat is better than nested"?

Jorgen Grahn grahn+nntp at snipabacken.se
Tue Oct 26 02:20:52 EDT 2010


On Mon, 2010-10-25, bruno.desthuilliers at gmail.com wrote:
> On 25 oct, 15:34, Alex Willmer <a... at moreati.org.uk> wrote:
>> On Oct 25, 11: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?
>>
>> I take this as a reference to the layout of the Python standard
>> library and other packages i.e. it's better to have a module hierarchy
>> of depth 1 or 2 and many top level items, than a depth of 5+ and only
>> a few top level items.
>>
> (snip)
>
> This also applies to inheritance hierarchies (which tend to be rather
> flat in Python compared to most mainstreams OOPLs), as well as nested
> classes etc.

Which mainstream languages are you thinking of?  Java?  Because C++ is
as flat as Python.

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .  .
\X/     snipabacken.se>   O  o   .



More information about the Python-list mailing list