[Python-ideas] mixins as decorators vs inheritance [was: Automatic comparisons by default]

Raymond Hettinger raymond.hettinger at gmail.com
Fri Mar 18 18:04:09 CET 2011

On Mar 18, 2011, at 6:58 AM, Mike Graham wrote:
> (a) is a misfeature. isinstance checks are bad: they make your code
> less flexible – in Python the actual type of an object isn't something
> we treat as semantic data. This is *especially* the case with mixins,
> which are just a convenient thing for code reuse, not some meaningful
> type.

I believe that is outdated advice.  Since Guido introduced 
abstract base classes, the trend (and grain) of Python is to
use isinstance() to check for a given interface (i.e. distinguishing
a Sequence from a Mapping) and to use ABCs as mixins
(i.e. MutableMapping has replaced UserDict.DictMixin).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110318/7662f138/attachment.html>

More information about the Python-ideas mailing list