[Python-ideas] Is multiple inheritance Pythonic?

Terry Reedy tjreedy at udel.edu
Fri Mar 18 23:16:28 EDT 2016


On 3/18/2016 6:34 PM, Martin Teichmann wrote:

> The problem they wanted to solve is that the behavior of
> BaseEventLoop.create_task should be changeable. Obvious,
> I thought (and did in my code) inherit from the class, overwrite
> the method! But what if I want to overwrite that method in
> something that inherits from BaseEventLoop, say, some
> QtEventLoop? No problem, I thought, just supply a
> Mixin, and a simple class EventLoop(AMixin, QtEventLoop)
> does the job. This is even chainable, multiple mixins can
> be used as long as they properly call super().

The derived subclasses, SelectorEventLoop and ProactorEventLoop, can be 
subclassed.  Four days ago I posted a trivial subclass that re-defined 
one method, .run_forever.  This allows the use of tkinter and asyncio 
together.  I hope it is not an accident that I was able to do so so 
easily ;-).

-- 
Terry Jan Reedy



More information about the Python-ideas mailing list