Overwrite just one line? Am I a n00b or is this impossible? Both? :D

Matt@revera electric.sunrise at gmail.com
Wed Apr 6 17:01:26 EDT 2005


I'd like to overwrite just one line of a binary file, based on a
position set by seek().  Is there no way to do this? As far as I can
tell I need to read the whole file, change the line, and write it all
back out.  Not exactly easy on the memory, but I see no other solution.

so far:

	patchme.seek(offset)
	patchme.write(a2b_hex(edit)) # the data is in hex first
	patchme.close
	print "Patching complete"

This writes the data at the given offset, but _everything_ before it is
filled with 0's.

Sorry for the potentially n00b question, I'm stumped!




More information about the Python-list mailing list