class DefaultLogger(object):

    def log(self, line):
        print(line)
_features = {'logger': DefaultLogger}

def set_feature(name, feature):
    _features[name] = feature

def get_feature(name):
    return _features[name]()


class Whatever(object):

    def dosomething(self):
        feature = get_feature('logger')
for i in range(5):
    feature.log('task %s' % i)
if __name__ == '__main__':


    class MyLogger(object):

        def log(sef, line):
            print('Cool', line)
set_feature('logger', MyLogger)
Whatever().dosomething()
Dependency Injection to modules