I'd do something like that :
# file : service_handler.py
from importlib import import_module
# get parameters from your config file beforehand
def get_backend(backend_name, **kwargs):
# example : foo.Spam gets backend Spam from module foo
backend_module, backend_class = backend_name.rsplit('.', 1)
mdl = import_module(backend_module)
cls = getattr(mdl, backend_class)
return cls(**kwargs) # create the object
Define your backends as you want to (using abstract classes or duck typing).
This is by no means a complete solution, rather a skeleton pattern that I saw and have done on several projects. You might want to add registry mechanisms, default backends, autodiscover... ymmv.
Projects like django do a lot of multiple-backend stuff, give their codebase a look.