Re: Handling sorted dictionaries

2007-04-17 Thread filyph
Hello, Dictionary items are inordered and can not be sorted. Function sorted() returns list of tuples in each is 0. item key from dictionary and 1. is value from key-value pair from dict machines. List indices must be integers and machine keys are strings. See http://www.python.org/dev/peps/pep-0

Re: Handling sorted dictionaries

2007-04-17 Thread Steven D'Aprano
On Tue, 17 Apr 2007 01:01:55 -0700, loial wrote: > The following code gives the error > > d=sortedmachines[machine] > TypeError: list indices must be integers > > > What works for the unsorted dictionary does not work for the sorted > dictionary. > Can anyone help? The error message you got te

Handling sorted dictionaries

2007-04-17 Thread loial
The following code gives the error d=sortedmachines[machine] TypeError: list indices must be integers What works for the unsorted dictionary does not work for the sorted dictionary. Can anyone help? machinekey = "11" machines = {} machines[machinekey]=[1,0,0,0,0,0,0,0,0,0,0,0,0] machinek