[Python-ideas] string codes & substring equality
spir
denis.spir at gmail.com
Mon Dec 2 12:55:42 CET 2013
On 12/02/2013 02:07 AM, MRAB wrote:
>> I think you missed one. The programmer says it's 4. :-)
>>
> No. The programmer used to say it was 4, but now says it's 4.5, give or
> take a little rounding error. :-)
[off topic]
Yop, I just discover that: which division is executed (integral or real) is now
determined by operator. Great reparation of a long-time Python bug, in my view:
python 3.3.1:
spir at ospir:~$ python3
Python 3.3.1 (default, Sep 25 2013, 19:29:01)
[GCC 4.7.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 9/2
4.5
>>> 9//2
4
>>> 9.0/2.0
4.5
>>> 9.0//2.0
4.0
>>>
python 2.7.4:
spir at ospir:~$ python2
Python 2.7.4 (default, Sep 26 2013, 03:20:26)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 9/2
4
>>> 9//2
4
>>> 9.0/2.0
4.5
>>> 9.0//2.0
4.0
[There remains a slight inconsistency, does't it? real div always returns a
float independently of args' types, while integral division return a float if
float args; is it in purpose? anyway, we'll survive it.]
Denis
More information about the Python-ideas
mailing list