No, no elif s. Just connect if s:
function(a if A else b if B else c)
Which is equivalent (like precedence from left to right):
function(a if A else (b if B else c))
Obviously this can get complicated (and over the PEP8 limit of 80 char), EG:
move(N if direction == "N" else E if direction == "E" else S if direction == "S" else W)
In this case, a longer form is better:
if direction == "N": move(N) elif direction == "E": move(E) elif direction == "S": move(S) else: move(W)
matsjoyce
source share