files and reading from them

Avi Homes Moo at houston.rr.com
Mon Mar 25 01:30:30 EST 2002


I am writing a dictionary to a file, like so
f.write(str(Info))

and what it is writing to the file is the following..
{'IPrice': '3', 'IName': 'lame lame', 'IDesc': 'stuff}

and if i write in two things, i get..
{'IPrice': '3', 'IName': 'lame lame', 'IDesc': 'stuff}
{'IPrice': '2', 'IName': 'notworking, 'IDesc': 'annoying'}

What i would like to do is pull a readline or somesuch.. and have it take in
the whole thing, and then just let me assign that to a empty name, and turn
it into a new dictionary.. like say
 file.seek(1)
//thats how i'd go to the first place in the file correct?
X=file.readline()

and now i can say print X['IName'] ... and its turned into a dictionary.. i
am most likely going about this *all* wrong.







More information about the Python-list mailing list