Convert hash to struct  Steven D'Aprano steve at Sat Jun 20
16:26:20 CEST 2009  Jason wrote:  > Here's my general-purpose
solution for doing this: > class Dict2Class(object): >     """ >
Update like a dictionary, but expose the keys as class
properties.  I'm afraid that's wrong. It's wrong twice:  *
Properties are computed attributes. These are not, they are
regular  * Class attributes are shared between all instances.
These are not, so they are instance attributes (or just regular
"attributes" without qualification), not class attributes.  >
def __init__(self, *e, **f): >         self.__dict__ = dict(*e,
**f)  You're updating the instance __dict__, not the class
__dict__. Hence they are instance attributes.  This is the
correct thing to do, but if you wanted to share keys and values
between all instances, you would use class attributes:
self.__class__.__dict__ = dict(*e, **f)  As far as properties,
in this case there's no sensible reason for making them
properties. (Properties have their uses, b