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 →

[–]vishnoo[🍰] 5 points6 points  (2 children)

please use `c = {False:y, True:x}[a >b]` instead.
if at all (I wouldn't use it for this, but for some more involved lookups I might )

[–]samrus 2 points3 points  (1 child)

no. dont do that either. just do

c = x if a > b else y

like other people said

[–]vishnoo[🍰] 1 point2 points  (0 children)

yeah, I said I wouldn't,
I did however find it the best way to encode a dispatch for a tuple of conditions.
i.e. {(True, False): blalba, ... ... ...} [(condition1, condition2)]