using marshal module
c.davis at actrix.co.nz
Wed Feb 2 05:17:08 CET 2000
I am new to python (but old(er) to C++); and trying to get a script to
work. What it is meant to do, is reads in a file, config.db and then
changes the values of one of the fields, and write the revised contents
back. if I call dump(<array where file contents loaded to>, <name of file
pointer>) no change seems to take place. (The field isn't changed, nor
does the field get concatenated at the end.
I have this feeling I may be missing out something important, but silly.
Here is the piece of broken code:
# open the file
fp = open(filename)
datastuff = marshal.load(fp)
# change the field
datastuff['field'] = 'new string of stuff'
# "write it back to the file"
# also tried "marshal.dump(datastuff, fp)" which didn't work either
# close the file
More information about the Python-list