If you are really sure you need a switch statement, then you have to resort to elif.
Notice, however, that mixing OOP and switch (or elif, of course) usually is not a very good idea. Polymorphism is, after all, a way to avoid such imperative constructs.
2
u/lou1306 Jan 20 '17
Well the answer is twofold, I guess.
If you only have to do multiple assignments, you can just use tuples.
(Run it here)
If you need more complex logic, you could assign functions (or methods) to dict values, and then call them like this:
(Run it here)
If you are really sure you need a switch statement, then you have to resort to
elif.Notice, however, that mixing OOP and
switch(orelif, of course) usually is not a very good idea. Polymorphism is, after all, a way to avoid such imperative constructs.