[Python-Dev] Re: Zen of Python

Skip Montanaro skip at pobox.com
Thu Jan 20 02:47:02 CET 2005


    Phillip> Actually, this is one of those rare cases where optimization
    Phillip> and clarity go hand in hand.  Human brains just don't handle
    Phillip> nesting that well.  It's easy to visualize two levels of nested
    Phillip> structure, but three is a stretch unless you can abstract at
    Phillip> least one of the layers.

Also, if you think about nesting in a class/instance context, something like

    self.attr.foo.xyz()

says you are noodling around in the implementation details of self.attr (you
know it has a data attribute called "foo").  This provides for some very
tight coupling between the implementation of whatever self.attr is and your
code.  If there is a reason for you to get at whatever xyz() returns, it's
probably best to publish a method as part of the api for self.attr.

Skip


More information about the Python-Dev mailing list