Oh Dear

bearophile bearophileHUGS at lycos.com
Sun Jul 12 18:29:09 PDT 2009


Walter Bright:
> If Python always used floor division, why did it add a // operator that 
> does exactly the same thing as / ?

See this (Python 2.6):

>>> 500 / 30
16
>>> 500 // 30
16
>>> 500 / 30.0
16.666666666666668
>>> 500 // 30.0
16.0
>>> from __future__ import division
>>> 500 / 30
16.666666666666668
>>> 500 // 30
16
>>> 500 / 30.0
16.666666666666668
>>> 500 // 30.0
16.0

// Always return a number with no fractional part.

That "future" is the default in Python 3+

Bye,
bearophile



More information about the Digitalmars-d mailing list