i am filling a dictionary with a dictionary and my values for
isegment[field] are identical.  i can't see where i am overwriting the
previous field values.

my data looks like

Field = aa1
Index = 0.0
Value = 0.0
...
...
 Field = aa2
Index = 0.01
Value = 0.5
...


i would like to have something like,  {1: {'Value': 0.0, ...}, 2: {'Value':
0.01, ...}}

for line in file(data_file):
    the_line = line.split()
    if the_line:
        if the_line[0] == 'Field':
            field += 1
        elif the_line[0] == 'Index':
            index = float(the_line[-1])
            dif_index = index - start_index
            iindex[field] = dif_index
            start_index = index
        elif the_line[0] == 'Value':
            segment[the_line[1]] = float(the_line[-1])*(ax/40)
            isegment[field] = segment


-- 
"The game of science can accurately be described as a never-ending insult to
human intelligence." - João Magueijo
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to