[New-bugs-announce] [issue17262] OrderedDict not ordering properly when int and float keys are used
Matthew Porter
report at bugs.python.org
Thu Feb 21 00:34:31 CET 2013
New submission from Matthew Porter:
I've got two lists:
state_cns_list = [0.001, 1, 2, 5]
state_names_list = [L, S, D, H]
When I try to create an OrderedDict linking each state_cns_list entry with its corresponding state_names_list entry, like so:
states = OrderedDict( {float(state_cns_list[i]): state_names_list[i] for i in range(0, len(state_cns_list) ) } )
rather than maintaining the original order, (0.001, 'L') is placed at the end of the OrderedDict instead of at the beginning. The attached screenshot shows the bug in action.
Although it's not in the screenshot, when I try placing 4 integers into state_cns_list instead of 3 integers and a float, it has no problem correctly ordering them.
----------
components: Library (Lib)
files: OrderedDictBug.png
messages: 182570
nosy: MrDrMcNinja
priority: normal
severity: normal
status: open
title: OrderedDict not ordering properly when int and float keys are used
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file29138/OrderedDictBug.png
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17262>
_______________________________________
More information about the New-bugs-announce
mailing list