In a class method I have a set of possible options for a single keyword argument, each with a different algorithm to calculate something. To check which option has been added to the keyword I made a chain of if, elif, else too find the keyword option provided.
class MyClass:
def my_method(self, my_parameter, my_keyword='spacial'):
if my_keyword == 'spacial':
print('Cool stuf')
elif my_keyword == 'discoidal':
print('OTHER cool stuff')
elif my_keyword == 'temporal':
print('You get the gist')
else:
print('not in options list')
In my opinion this is not a very elegant way to code this. Especially if the options list keeps growing. Is there a way to omit the list of if, elif, elif, else statements?