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

Jack Diederich jackdied at gmail.com
Fri Mar 18 16:39:45 CET 2011


On Fri, Mar 18, 2011 at 8:59 AM, Jim Jewett <jimjjewett at gmail.com> wrote:
> On Thu, Mar 17, 2011 at 9:48 AM, Mike Graham <mikegraham at gmail.com> wrote:
>> On Wed, Mar 16, 2011 at 5:48 PM, Masklinn <masklinn at masklinn.net> wrote:
>>> (also, since I apparently completely missed this,
>>> what was the rationale of making it a class
>>> decorator rather than, say, a mixin?)
>
>> Perhaps the better question is "Why do we ever
>> do mixins through inheritance?"
>
> That is a good question, and I was tempted to switch,
> until I realized that there are some good answers...
>
> (a)  So we can do an isinstance check
> (b)  So we can more easily override parts of the mixin

total_ordering won't override methods you've explicitly written.   And
IMO mixins were always a work-around and not a feature.  Class
decorators are a cleaner way of doing a similar thing.

-Jack



More information about the Python-ideas mailing list