I'd personally do something like this.

file = open(myfile, 'r')
fileContents = file.readlines() # read the entire document into memory for speed.
file.close()

print fileContents[-1] # This is the last line.

On 10/19/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
My algorithm is like this:
first count the number of lines in the file by using a loop.
Use a second loop and when teh counter reaches the num_of_lines values: take the line.
 
Is there any other way to do it??


 
On 10/19/06, Danny Yoo <[EMAIL PROTECTED] > wrote:


On Thu, 19 Oct 2006, Asrarahmed Kadri wrote:

> I want to extract the last line of the text file. Any idea ???

Hi Asrarahmed,

Ok, so what part do you get stuck on when you try to do this?  That is,
what sort of things do you already know how to do with files?



--
To HIM you shall return.

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to