Automatically Writing a Dictionary

tonylabarbara at aol.com tonylabarbara at aol.com
Wed Jan 23 20:19:02 CET 2008


Hi;
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 += "}"
input.close()


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

________________________________________________________________________
More new features than ever.  Check out the new AOL Mail ! - http://webmail.aol.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080123/12883d26/attachment.html>


More information about the Python-list mailing list