On Aug 17, 3:43 pm, TYR <[EMAIL PROTECTED]> wrote: > > So the tougher problem seems to be parsing those lines. That is not a > > valid Python dictionary unless the names `Bob`, `Humboldt`, `red`, and > > `predatory` are not already defined. So you can't just ``eval`` it. > > In what way? {'key': val}, right? > > Anyway, I can always change the format they go into the file in.
If you control the file format then you could create a valid python list of dictionaries as the intermediate file format. Something like: data = [ {'name' : 'Bob', 'species' : 'Humboldt', 'colour' : 'red', 'habits' : 'predatory'}, { ... }, ... } You can then name the file with a .py ending and import it as a list of dictionaries that you can then process to form a dict of dicts: datadict = dict( (data2name(d), d) for d in modulename.data ) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list