4 ms·
As pointed out in the OP, there are actually quite a lot of ways to simulate the ternary operator in Python. An interesting one is (result, alternative)[test].
by IgorPartola 16y ago
As pointed out in the OP, there are actually quite a lot of ways to simulate the ternary operator in Python. An interesting one is (result, alternative)[test]. If result and alternative are functions you could write it as (result, alternative)[test]().
And for desert: I love this syntax:
if 0 < x <= 100: pass
For more info see: http://stackoverflow.com/questions/394809/python-ternary-operator http://stackoverflow.com/questions/394809/python-ternary-ope...