a *= b not equivalent to a = a*b

Peter Otten __peter__ at web.de
Fri Aug 26 05:11:10 EDT 2016


mlzarathustra at gmail.com wrote:

> Yes, I just worked that out. It's the integer math that's the problem.
> 
> I guess this has been fixed in python 3, but unfortunately it seems that
> most people are still using python 2.

Note that you can get Python 3's default behaviour in Python 2 with

from __future__ import division

at the beginning of the module.

>>> 2/3
0
>>> from __future__ import division
>>> 2/3
0.6666666666666666






More information about the Python-list mailing list