I have 5 sets of request's categories defined as python dicts, for example:
category1 = {'type1', 'type2', 'type3'}
category2 = {'type4', 'type5'}
category3 = {'type6', 'type7', 'type8', 'type9'}
category4 = {'type10', 'type11'}
category5 = {'type12', 'type13', 'type14'}
And I need to handle requests using their category, for instance:
if request_type in category1:
# process category1 request
process_category1_request(...)
elif request_type in category2:
# process category2 request
process_category2_request(...)
elif...
and I need to dispatch a request using the request type to a different function to process it.
I already know there are ways of dispatching this requests in Python without the need of using if-elif, but my question is: what's the best way to do it while maintaining the code clean and simple?