math.pow(a,n) versus ** operator
Fredrik Lundh
effbot at telia.com
Mon Oct 16 02:16:49 EDT 2000
Kirby wrote:
> However, ** also seems just plain wrong when raising a
> negative to the 0th power:
>
> >>> -1**0 # this is wrong
> -1
quoting the language reference:
"The power operator binds more tightly than unary
operators on its left; it binds less tightly than unary
operators on its right"
in other words, you're calculating -(1**0), not (-1)**0
>>> x = -1
>>> x ** 0
1
</F>
More information about the Python-list
mailing list