truncating a file from the top down

rbt rbt at athop1.ath.vt.edu
Tue Mar 29 18:36:48 CEST 2005


Hi guys,

I need to truncate a file from the top down. I imagine doing something 
like this:

if os.stat says the file is too big:
     read the file
     trim = only keep the last 2008 bytes (This is where I get stuck)
     write trim back out to the original file

Would someone demonstrate the *best* most efficient way of doing this?

Thanks,
rbt





More information about the Python-list mailing list