[issue21993] counterintuitive behavior of list.index with boolean values

Wolfgang Maier report at bugs.python.org
Wed Jul 16 23:55:22 CEST 2014


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 (since the empty string evaluates to False).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21993>
_______________________________________


More information about the Python-bugs-list mailing list