Automatically Writing a Dictionary

tonylabarbara at tonylabarbara at
Wed Jan 23 20:19:02 CET 2008

I have data in a file and I would like to write it to a dictionary, and then perform commands on it, something like this:

input = "/usr/local/machine-lang-trans/dictionary.txt"

input = open(input,'r')

dict = "{"
for line in input:
? tup = re.split(','line)
? dict += '"' + tup[0] +'":"' + tup[1] +'", '
dict += "}"

Of course, that will just give me a string. How do I convert it to, or make from scratch, a dictionary of that?

More new features than ever.  Check out the new AOL Mail ! -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list