[issue44692] Const folding in parser with negative numbers doesn't match float/int behaviour
Steven D'Aprano
report at bugs.python.org
Wed Jul 21 01:26:37 EDT 2021
Steven D'Aprano <steve+python at pearwood.info> added the comment:
Not a bug, this is due to operator precedence.
It is documented under the power operator:
https://docs.python.org/3/reference/expressions.html#the-power-operator
and in the operator precedence table:
https://docs.python.org/3/reference/expressions.html#operator-precedence
If you want to raise a negative literal to a power, you need parentheses:
(-2)**2
----------
nosy: +steven.daprano
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44692>
_______________________________________
More information about the Python-bugs-list
mailing list