Wolfgang Maier added the comment:
Right, forgot about that.
The consequence for the example is still far from satisfying, I think, but you
can't change it without breaking compatibility then.
Thanks for the quick reply,
Wolfgang
--
___
Python track
Ezio Melotti added the comment:
'a' evaluates to true, but it's not equal to True:
>>> bool('a')
True
>>> 'a' == True
False
but 1 and True are equal (for historical reasons):
>>> 1 == True
True
Similarly '' evaluates to false, but it's not equal to False:
>>> bool('')
False
>>>
Wolfgang Maier added the comment:
No, it's not that simple and I don't think this should be closed:
In my example:
>>> l = ['a', '', {}, 2.7, 1, 0, False, True]
>>> l.index(True)
4
>>> l.index(False)
5
if using __eq__ consistently, you'd expect the first call to return 0 and the
second 1 (sinc
Ezio Melotti added the comment:
It's using __eq__:
>>> l = [3, 1.0, 5, True, 7, 1]
>>> l.index(1)
1
>>> l.index(True)
1
>>> l.index(1.0)
1
>>> True == 1 == 1.0
True
--
nosy: +ezio.melotti
resolution: -> not a bug
stage: -> resolved
status: open -> closed
__
New submission from Wolfgang Maier:
>>> l = [False, True]
>>> l.index(True)
1
>>> l.index(False)
0
good, but:
>>> l = ['a', '', {}, 2.7, 1, 0, False, True]
>>> l.index(True)
4
>>> l.index(False)
5
Apparently, True and False get converted to int in comparisons to ints.
I would expect items to b