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:
>
>> 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
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
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