[New-bugs-announce] [issue21993] counterintuitive behavior of list.index with boolean values
Wolfgang Maier
report at bugs.python.org
Wed Jul 16 23:43:37 CEST 2014
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 be compared either by:
a) object identity or
b) __eq__
but not this inconsistently.
Best,
Wolfgang
----------
components: Interpreter Core
messages: 223284
nosy: wolma
priority: normal
severity: normal
status: open
title: counterintuitive behavior of list.index with boolean values
type: behavior
versions: Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21993>
_______________________________________
More information about the New-bugs-announce
mailing list