Martin Franklin wrote:
> import gzip
> log_file = gzip.open("access_log.4.gz")
> last_line = log_file.readlines()[-1]
> log_file.close()

does the
log_file.readlines()[-1]
actually read all the lines first?

i switched to system call with tail because originally i was using a
pure Python solution

         inF = gzip.GzipFile(ff, 'rb');
         s=inF.readlines()
         inF.close()
         last_line=s[-1]

and since the log file is 100 megabytes it takes a long time and hogs
massive memory.

 Xah
 [EMAIL PROTECTED]
∑ http://xahlee.org/

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to