IntroductionBrief documentation. For more details see the code. Installationeasy_install IoC Usagefrom IoC import *
# somewhere in your code determine which class provides which features
sl = ServiceLocator()
sl.provide("some_feature", SomeClassOfYours)
# somewhere else in your code ask for the managed requirement, it will be resolved dynamically
#
class SomeOtherClass(object):
def __init__(self):
self.some_feature = ManagedRequirement("some_feature")
## when you do
soc = SomeOtherClass()
soc.some_feature.blah()
# the ServiceLocator will be used to find the right implementation
|