Re: AtrributeDict

2009-04-29 Thread alex23
On Apr 30, 9:09 am, Дамјан Георгиевски wrote: > I've needed an attribute accessible dict, so I created this. > Are there any obviously stupid shortcomings? > > class AttrDict(dict): >    def __getattr__(self, name): >        try: >            return self[name] >        except KeyError, e: >      

Re: AtrributeDict

2009-04-29 Thread Дамјан Георгиевски
>> I've needed an attribute accessible dict, so I created this. >> Are there any obviously stupid shortcomings? > > If you know the attribute names ahead of time, you might consider > using a namedtuple instead. > See > http://docs.python.org/library/collections.html#collections.namedtuple I do u

Re: AtrributeDict

2009-04-29 Thread Chris Rebert
2009/4/29 Дамјан Георгиевски : > I've needed an attribute accessible dict, so I created this. > Are there any obviously stupid shortcomings? If you know the attribute names ahead of time, you might consider using a namedtuple instead. See http://docs.python.org/library/collections.html#collections

AtrributeDict

2009-04-29 Thread Дамјан Георгиевски
I've needed an attribute accessible dict, so I created this. Are there any obviously stupid shortcomings? class AttrDict(dict): def __getattr__(self, name): try: return self[name] except KeyError, e: raise AttributeError(e) -- дамјан ( http://softver.org.m