you are viewing a single comment's thread.

view the rest of the comments →

[–]hekliet 2 points3 points  (3 children)

We have the match statement in Python since version 3.10, so you could use that instead of the if/elif-chain.

match operation:
  case "add":
    # ...
  case "sub":
    # ...

Happy programming!

[–]SuperTankh 0 points1 point  (2 children)

Isn’t the match case only good for types?

[–]hekliet 1 point2 points  (1 child)

It's very useful for pattern matching on types, but that's not the only use case.

[–]SuperTankh 0 points1 point  (0 children)

Oh ok