[Python-Dev] Updated Monkey Typing pre-PEP

Steven Bethard steven.bethard at gmail.com
Thu Jan 20 18:34:55 EST 2005

On Thu, 20 Jan 2005 18:21:17 -0500, Raymond Hettinger <python at rcn.com> 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:

You can wordify anything if you just verb it.
        --- Bucky Katt, Get Fuzzy

More information about the Python-list mailing list