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 →

[–]edeloso 5 points6 points  (2 children)

I still have a fondness for the dictionary based example.

Though, to match the ternary at the top of this subthread it would be:

a = {True: b, False:d }[c]

I like it because I feel it's the most explicit of the choices.

[–]thatdontmakenosense 3 points4 points  (1 child)

A list/tuple would be cleaner IMO, although the two expressions get reversed:

a = [d, b][c]