[issue42428] Inconsistent squaring behavior

2020-11-21 Thread Christian Heimes
Christian Heimes added the comment: Operator precedence and unary operator binding is explained in the language reference documentation, https://docs.python.org/3/reference/expressions.html#the-power-operator -- nosy: +christian.heimes resolution: -> not a bug stage: -> resolved st

[issue42428] Inconsistent squaring behavior

2020-11-21 Thread Mark Dickinson
Mark Dickinson added the comment: -3 ** 2 is parsed by Python as -(3 **2), not as (-3) ** 2. -- nosy: +mark.dickinson ___ Python tracker ___ __

[issue42428] Inconsistent squaring behavior

2020-11-21 Thread JohnSmith11132
New submission from JohnSmith11132 : Basically when squaring as a negative number, if it's a variable it acts like -3*-3 otherwise it acts like 3*-3. For example: >>> x = -3 >>> x ** 2 9 >>> -3 ** 2 -9 pow(-3, 2) seems to act like -3 * -3? ** 3 seems fine and both seems to act like -3*-3*-3. >