I am writing a class which should subclass, amongst other classes, code.InteractiveInterpreter. For some reason, one of the methods that that class normally has (compile) is not available on its subclasses when you use multiple inheritance.
Single inheritance works fine:
>>> from code import InteractiveInterpreter
>>> class Single(InteractiveInterpreter): pass
...
>>> hasattr(Single(), 'compile')
True
Multiple inheritance does not:
>>> class Double(object, InteractiveInterpreter): pass
...
>>> hasattr(Double(), 'compile')
False
Flipped the order around though, it works:
>>> class Flipped(InteractiveInterpreter, object): pass
...
>>> hasattr(Flipped(), 'compile')
True
Is there some subtle detail of multiple inheritance that I'm unaware of that is preventing compile from being inherited in some cases, or is there a bug in Python causing this (given the name of the method in question is also the name of a built-in function, I feel like this might be possible.)
I'm trying to reproduce the issue with a class other than InteractiveInterpreter but am unable to... this works fine:
>>> class Original():
... def compile(self): pass
...
>>> class Secondary(object, Original): pass
...
>>> hasattr(Secondary(), 'compile')
True
I'm using Python 2.7.11, 32 bit, on Windows 10.