On Nov 15, 9:48 am, Chris Rebert <c...@rebertia.com> wrote: > On Sun, Nov 14, 2010 at 10:39 PM, Dmitry Groshev <lambdadmi...@gmail.com> > wrote: > > Here are some proposals. They are quite useful at my opinion and I'm > > interested for suggestions. It's all about some common patterns. > <snip> > > Second, I saw a lot of questions about using dot notation for a > > "object-like" dictionaries and a lot of solutions like this: > > class dotdict(dict): > > def __getattr__(self, attr): > > return self.get(attr, None) > > __setattr__= dict.__setitem__ > > __delattr__= dict.__delitem__ > > why there isn't something like this in a standart library? > > There > is:http://docs.python.org/library/collections.html#collections.namedtuple > > The "bunch" recipe is also fairly well-known; I suppose one could > argue whether it's > std-lib-worthy:http://code.activestate.com/recipes/52308-the-simple-but-handy-collec... > > Cheers, > Chris
namedtuple is not a "drop-in" replacement like this "dotdict" thing - you first need to create a new namedtuple instance. As for me it's a bit too complicated. -- http://mail.python.org/mailman/listinfo/python-list