semantics of ** (unexpected/inconsistent?)

Brian J Mingus Brian.Mingus at Colorado.EDU
Mon Nov 30 20:42:06 CET 2009


On Sun, Nov 29, 2009 at 5:58 PM, Esmail <ebonak at hotmail.com> wrote:

> Brian J Mingus wrote:
>
>>
>>
>>
>> I think you answered your own question. 3**2 comes first in the order of
>> operations, followed by the negation.
>>
>
> No, that's not the problem, I'm ok with the operator precedence of - vs **
>
> My problem is why I don't get the same result if I use the literal -3 or
> a variable that contains -3 (x in my example)


Yes, that is the problem. Setting x=-3 is the same as writing (-3)**2 vs.
-(3**2).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091130/e3374103/attachment.html>


More information about the Python-list mailing list