[issue8353] Negative exponentiation behaving oddly in python shell

Martin v. Löwis report at bugs.python.org
Fri Apr 9 08:16:04 CEST 2010


Martin v. Löwis <martin at v.loewis.de> added the comment:

This is expected behavior. The power operator binds with higher precedence than the unary minus:

http://docs.python.org/reference/expressions.html#unary-arithmetic-and-bitwise-operations

Therefore, your term is interpreted as

-(4 ** 2)

As for "it only affects the prompt": I can't reproduce that. If I put

print(-4**2)

in a script and run that, it still prints -16 for me.

----------
nosy: +loewis
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8353>
_______________________________________


More information about the Python-bugs-list mailing list