A note about the ordering of mixin classes

In Python, when you have a class that inherits from both a primary class and some mixin classes (for example, if you're using the SocketServer stuff ), it's conventional to declare your class's inheritance list with the primary class first:

class Real(primary, mixin1, mixin2):
    ....

However, an important safety tip: if your mixin class overrides methods of the primary class, it has to be first . Failure to observe this safety tip can cause head-scratching bugs followed by head-smacking embarrassment.

(Since I was mixing stuff in to standard types like list and tuple and str , I spent a certain amount of time wondering if the interpreter had special direct magic for them that meant I couldn't hijack and augment their standard behavior. I felt somewhat foolish when there turned out to be a much simpler explanation.)