Nick Coghlan <[EMAIL PROTECTED]> wrote: ... > Michael Spencer also posted an interesting idea recently about setting up > a view of an existing dictionary, rather than as a separate object: > > class attr_view(object): > def __init__(self, data): > object.__setattr__(self, "_data", data) > def __getattr__(self, attrname): > return self._data[attrname] > def __setattr__(self, attrname, value): > self._data[attrname] = value
Wasted indirection, IMHO. A better implementation: class attr_view(object): def __init__(self, data): self.__dict__ = data Alex -- http://mail.python.org/mailman/listinfo/python-list