How to read lines only at the end of file?

Batista, Facundo FBatista at uniFON.com.ar
Fri Nov 7 07:33:55 EST 2003


Christopher Koppler wrote:

#- You could do the following:
#- 
#- >>> f = file('filename.txt', 'r')
#- >>> numberoflines = 10
#- >>> for line in f.readlines()[-numberoflines:]:
#- ...     print line
#- 
#- which prints the last 10 lines of the file.

But if the file has 2GB? This method doesn't reads *all* the file?

.	Facundo





More information about the Python-list mailing list