Precidence of unary plus/minus relative to exponentiation

Warnes, Gregory R gregory_r_warnes at groton.pfizer.com
Tue Apr 1 12:40:21 EST 2003


The current operator precedence places unary plus and minus higher than
exponentiation.  This leads the counterintuitive result:

	>>> -2.0**2.0
	-4.0
	
Python's operator predicence is causing this to be interpreted as:

	>>> -(2.0**2.0)

rather than the normal mathematical precidence, which would give

	>>> (-2.0)**2.0

Is there a good reason for the Python order of precedence?

-Greg


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.





More information about the Python-list mailing list