I am trying to reduce cylomatic complexity of code, because according to pylama my definition is 'too complex' and suggested solution includes calling functions with dictionary mappings.
So I tried it on my object oriented code but failed miserably.
class trial:
def __init__(self):
self.a = 'a'
self.b = 'b'
def a(self):
return self.a
def b(self):
return self.b
def select_one(self, option):
map_func = {
1 : self.a,
2 : self.b
}
return map_func[option]()
t = trial()
print(t.select_one(1))
If this is not possible what are the other possible solutions to reduce cyclomatic complexity.