def factory(name): for fname, obj in inspect.getmembers(sys.modules[__name__]): if inspect.isclass(obj): if name == fname: return obj from otest.aus import operation obj = operation.factory(name) if not obj: raise Unknown("Couldn't find the operation: '{}'".format(name)) return obj