On Mon, Apr 04, 2022 at 08:28:31AM +1000, Chris Angelico wrote:
What do you intend for dependency injection to do with this scream method? What would make sense? You've already designed something that works differently.
I don't know why malmiteria keeps talking about dependency injection. None of his examples show dependency injection. https://www.jamesshore.com/v2/blog/2006/dependency-injection-demystified In Python, dependency injection is usually called "passing an object to the constructor". # No dependency injection. class Car: def __init__(self): self.engine = Engine() # With dependency injection. class Car: def __init__(self, engine): self.engine = engine mycar = Car(Engine()) test_car = Car(MockEngine()) With duck typing, the car's dependency, the engine, doesn't have to be an instance of Engine. It can be anything that quacks like an engine: a proxy, a mock engine, a thousand hamsters in wheels, whatever you want to pass in as the dependency, so long as it has the right interface. In the design pattern world, millions of words have been written about this. (The DP folks love to over-engineer their code.) In Python, we just call it passing in an object :-) In any case, it has nothing to do with super or the MRO. -- Steve