Pythonic style

Ben Finney ben+python at benfinney.id.au
Wed Apr 27 23:23:31 EDT 2016


Christopher Reimer <christopher_reimer at icloud.com> writes:

> In short,  my original code before I turned it into a separate
> dictionary. *sigh*

No, I think that misses the points that were being made. The discussion
you're talking about was *not* to say “attribute access is better than
dictionary access”, or vice versa. Each is good for its purpose.

Rather, the discussion was to drive home the point that in Python those
are *two distinct concepts*, and you need to not conflate them.

If you want items in a mapping, explicitly use a Python ‘dict’ instance.
If you want attributes that describe an object, explicitly use
attributes of that object. Deliberately choose which one makes more
sense.

-- 
 \         “The double standard that exempts religious activities from |
  `\       almost all standards of accountability should be dismantled |
_o__)                   once and for all.” —Daniel Dennett, 2010-01-12 |
Ben Finney




More information about the Python-list mailing list