On Thu, 20 Jan 2005 18:21:17 -0500, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > Instead of a __getattr__ solution, I recommend subclassing from a mixin: > > class RichMap(SomePartialMapping, UserDict.DictMixin): pass > > class RichFile(SomePartialFileClass, Mixins.FileMixin): pass
I've been wondering for a while if there shouldn't be a mixins module for these kind of things. DictMixin, of course, and a maybe ListMixin to add extended slicing, append, extend, index, etc. I can see that a FileMixin might also be useful... If a mixins module was created, it would also give us the opportunity to break backwards compatibility with DictMixin and base it off of __getitem__(), __setitem__(), __delitem__(), and __iter__() instead of __getitem__(), __setitem__(), __delitem__(), and keys(). (According to the language reference, the __iter__ method is much more integral to mapping types than the keys method: http://docs.python.org/ref/sequence-types.html) Steve -- You can wordify anything if you just verb it. --- Bucky Katt, Get Fuzzy -- http://mail.python.org/mailman/listinfo/python-list