On Thu, 31 Dec 2015 11:21:59 +1100, Ben Finney wrote: > Steven D'Aprano <st...@pearwood.info> writes: > >> On Thu, 31 Dec 2015 10:13 am, Ben Finney wrote: >> >> > You may be familiar with other languages where the distinction >> > between “attribute of an object” is not distinct from “item in a >> > dictionary”. Python is not one of those languages; the distinction is >> > real and important. ... > > Tersely: the relationship between an object and its attributes, is not > the same as the relationship between a dictionary and its items.
I understand this to mean that the relationship between a dictionary and its items is less complex than the relationship between an object and its attributes. I'd like to catalog the different attribute types/implications: - perhaps a hierarchy of meta-ism - or user-relevance - those things in the __dict__ - those things not in the __dict__ but without the "__" - ??? > >> Obviously there is a syntax difference between x.attr and x['key'] > > Not merely syntax; the attributes of an object are not generally > available as items of the container. What are the set of ways that an attribute is accessible? Including implementation implications? > >> Either the instance __dict__, the class __dict__, or a superclass >> __dict__. > > No, I'm not referring to the ‘__dict__’ attribute of an object; I'm > referring to the object itself. > > To talk about the attributes of an object ‘foo’ is distinct from talking > about the items in a dictionary ‘foo’. That distinction is real, and > important. But wanting to deal with the attributes of an object without considering the way it's implemented - although possible - requires a complete virtual model that covers all implications. It's easier to simply understand how the objects work under the covers. -- https://mail.python.org/mailman/listinfo/python-list