a *= b not equivalent to a = a*b
BartC
bc at freeuk.com
Fri Aug 26 05:48:11 EDT 2016
On 26/08/2016 08:14, mlzarathustra at gmail.com wrote:
> However, precedence wasn't the problem in this case, it was the type conversion.
I think it was. I was puzzled as well.
But apparently if you have:
x * = expr
That's like:
x = x * (expr) # note the parentheses
which may not always be the same as:
x = x * expr
as the latter may depends on how operators within expr relate to the
'*'. In your example, "/" within expr has the same precedence as "*" is
the "*" is done first not last.
The type conversion may be another issue, but it doesn't explain why the
results with the /same version/ of Python are different.
--
Bartc
More information about the Python-list
mailing list