0 + not 0

Chris Angelico rosuav at gmail.com
Sat Jul 11 14:05:03 CEST 2015


On Sat, Jul 11, 2015 at 9:54 PM, candide <c.candide at laposte.net> wrote:
> Le samedi 11 juillet 2015 13:31:03 UTC+2, Luuk a écrit :
>
>>
>> But operator precedence of 'not' is higher than of '+' ????
>
>
> Right but what does this prove? For instance, unary minus has higher precedence than exponentiation but the expression
>
> 2 ** -1
>
> doesn't raise a syntax error.

You'll see down below a footnote referring to this as a special case.
But I don't know the details of how it all works, so short of digging
into the source code, I can't explain this any better. There are
others on this list who can, I believe.

ChrisA


More information about the Python-list mailing list