[Tutor] Truncate First Line of File
Alex Ezell
aezell at gmail.com
Wed Feb 27 23:46:04 CET 2008
I must be missing some simple method on a file object or something.
What I need to do is to truncate the first line of a file which has an
unknown number of lines and an unknown size.
The only thing I can think to do is to readlines() and then slice off
the first line in the resulting list, then writelines().
pseduo-code:
my_file = open('file.txt', 'wb')
lines = my_file.readlines()
del lines[0]
my_file.writelines()
my_file.close()
Is there a better way?
/alex
More information about the Tutor
mailing list