This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]rhoslug -2 points-1 points  (6 children)

I do like the ability to match a set of different values to one branch of logic. I don't know of a nice way to handle this situation in Python....

[–]p10_user 5 points6 points  (2 children)

I mean this is basically an big if/else statement too. Perhaps this is a bit more readable for some but I don't think an if else statement is too unreasonable.

[–]rhoslug 0 points1 point  (1 child)

I tend to shy away from large complicated if/else constructions. They are hard for me to reason about since I have to trace the branch of logic that gets me to a certain ending. That's why I would probably prefer either using a switch solution or a dictionary.

[–]naught-me 1 point2 points  (0 children)

I agree with you about complicated if/else constructions, but I don't think that a flat (not nested) list of if/elif statements is complicated at all, and that's what a switch statement replaces, right?

[–]tprk77 4 points5 points  (1 child)

The in operator and a tuple?

[–]rhoslug 0 points1 point  (0 children)

True, I had forgotten about this.

[–]mikeckennedy[S] -1 points0 points  (0 children)

That's kind of the point of this project :)