# L-22 MCS 260 Wed 17 Oct 2007 : bklist2dict # # converts existing formats of books from # # [True, 1, 'The Art & Craft of Computing'] # [False, 2, 'Making Use of Python'] # # into # # {'available':True, 'key':1, 'title':'The Art & Craft of Computing'} # {'available':False, 'key':2, 'title':'Making Use of Python'} # infile = open('bookslists','r') outfile = open('booksdicts','w') while True: s = infile.readline() if s == '': break L = eval(s) d = {'available':L[0], 'key':L[1], \ 'title':L[2] } outfile.write(str(d) + '\n') infile.close() outfile.close()