inversion-of-control

Inject different implementation based on yaml configuration

Inject different implementation based on yaml configuration Question: Using python package dependency injector, I need to instantiate/inject a different implementation of an interface based on a yaml configuration file. class SomeInterface(abc.ABC): @abc.abstractmethod def some_method(self): pass class Impl1(SomeInterface): def some_method(self): # e.g. file-based implementation class Impl2(SomeInterface): def some_method(self): # e.g. service-based implementation I have different yaml …

Total answers: 1

What's the Python version for “Code against an interface, not an object”?

What's the Python version for “Code against an interface, not an object”? Question: Inspired by a great question (and bunch of great answers) from here. Does the statement “Code against an interface, not an object” have any significance in Python? I’m looking for answers like the ones in the Original Question but with Python snippets …

Total answers: 4

Why is IoC / DI not common in Python?

Why is IoC / DI not common in Python? Question: In Java IoC / DI is a very common practice which is extensively used in web applications, nearly all available frameworks and Java EE. On the other hand, there are also lots of big Python web applications, but beside of Zope (which I’ve heard should …

Total answers: 18