Hi, I have a text file called a.txt:
# comments [('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})] [('recId', 5), ('parse', {'pos': u'np', 'gen': u'm'})] [('recId', 7 ), ('parse', {'pos': u'np', 'gen': u'm'})] I read it using this: filAnsMorph = codecs.open('a.txt', 'r', 'utf-8') # Initialise input file dicAnsMorph = {} for line in filAnsMorph: if line[0] != '#': # Get rid of comment lines x = eval(line) dicAnsMorph[x[0][1]] = x[1][1] # recid is key, parse dict is value But it crashes every time on x = eval(line). Why is this? If I change a.txt to: # comments [('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})] it works fine. Why doesn't it work with multiple lines? it's driving me crazy! Thanks, Matthew -- http://mail.python.org/mailman/listinfo/python-list