[Python-Dev] Order of operations

Scott Dial scott+python-dev at scottdial.com
Thu Aug 30 07:49:10 CEST 2007

Martin v. Löwis wrote:
> Alexandre Vassalotti schrieb:
>> C doesn't have an exponentiation operator. You use the pow() function, instead:
> Right. Then Scott's claim ("Because it is consistent with C's precedence
> rules.") can't be true - from C precedence, it does not follow that **
> must have higher precedence than unary -.

I believe the confusion with my claim is that I thought the oddity in 
question was that -3/2 != 0-3/2, but I believe you took the other half 
about exponentiation as the oddity in question that -3**2 == -(3**2). My 
original comment was to say that unary - was higher precedence than 
division because of C's ordering. With respect to the original question, 
then my answer was poor as I ignored the exponentiation part. Since we 
tacked this on, my answer was to be an implicit zen answer of "because 
it makes the most sense."

Sorry for the added noise.


Scott Dial
scott at scottdial.com
scodial at cs.indiana.edu

More information about the Python-Dev mailing list