Andy Leszczynski wrote: > Chris F.A. Johnson wrote: >> And to answer the question in the subject line: >> >> last_line = file(argv[1]).readlines()[-1] >> >> Both of which assume "from sys import argv". > > What if a file is long enough?
Huh? You mean what if it's too big to fit in memory? Then try this: for last_line in file(argv[1]): pass At the end of the for loop, last_line should be bound to the last line in the file. (If there's a chance your file might not have any lines, you'll want to do some error checking...) STeVe -- http://mail.python.org/mailman/listinfo/python-list