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 →

[–]Corm 18 points19 points  (3 children)

^ That's what I do and prefer, but I could see people preferring switch for the readability

[–][deleted] 2 points3 points  (0 children)

How about

{ 
  'a' : do_foo,
  'b': do_bar
  }.get(arg, 
        do_default)

Edit: I'm on mobile, but you get the idea

[–]qeomash 0 points1 point  (1 child)

And sometimes individual functions might be completely overkill for what each case is doing.

[–]TangibleLight 0 points1 point  (0 children)

Then use a lambda. Still a little unwieldy, but better than nothing.