https://stackoverflow.com/questions/394809/does-python-have-a-ternary-conditional-operator
(falseValue, trueValue)[test == True]
or you can use the built-in bool() to assure a Boolean value:
bool()
(falseValue, trueValue)[bool(<expression>)]
No comments:
Post a Comment