0

I have the following construction with a long list of around 100 if .. elif. Is there a way do handle this more elegantly in python?

   if isinstance(scen_dep, Class1):
        scen_deps[someEnum.class2].append('1')
   elif isinstance(scen_dep, Class2):
        scen_deps[someEnum.class2].append('1')
   elif isinstance(scen_dep, Class3):
        scen_deps[someEnum.class3].append('1')
Nickpick
  • 6,163
  • 16
  • 65
  • 116

0 Answers0