admin管理员组文章数量:1404774
I checked python operator precedence
Operators in the same box group left to right (except for exponentiation and conditional expressions, which group from right to left).
** Exponentiation [5]
if – else Conditional expression
I can understand exponentiation that 2**3**2
is equal to 2**(3**2)
. But Conditional expression
conditional_expression ::= or_test ["if" or_test "else" expression]
is not one binary operator. I can't give one similar example as **
. Could you give one example of "group from right to left" for if
Conditional expression?
I checked python operator precedence
Operators in the same box group left to right (except for exponentiation and conditional expressions, which group from right to left).
** Exponentiation [5]
if – else Conditional expression
I can understand exponentiation that 2**3**2
is equal to 2**(3**2)
. But Conditional expression
conditional_expression ::= or_test ["if" or_test "else" expression]
is not one binary operator. I can't give one similar example as **
. Could you give one example of "group from right to left" for if
Conditional expression?
1 Answer
Reset to default 2a if b else c if d else e
means
a if b else (c if d else e)
and not
(a if b else c) if d else e
本文标签: pythonHow do conditional expressions group from right to leftStack Overflow
版权声明:本文标题:python - How do conditional expressions group from right to left? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744848390a2628349.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论