Python dictionary syntax, need help

Crew Reynolds crewr at daydots.com
Fri Jul 18 21:42:06 CEST 2003


I want to create a dictionary of note on/off timings and access it by
the name of the object. The following code works for one row.

a = "Hammer1" 
b = [5,45,45,45,45,50,55,57,59,61,60,59] 

notes = {a:b} 
print notes["Hammer1"][3] 
>>> 45 

The problem is, I want to load the data from a file to populate
variables a and b and build a dictionary for "Hammer1" thru
"Hammer10". That way, I can stick the name of the object in the array
index and receive a list of note timings that I can index with an
ordinal as in the above example.

This is straight Python syntax but I'm hoping someone has done this or
understands the syntax better than I.

Thanks! Alternative solutions to this concept would be greatly
appreciated.




More information about the Python-list mailing list