"ray sa" <[EMAIL PROTECTED]> wrote

> used in UNIX called the tail command.
>
> May be someone can help me to achieve the same result with modifying 
> the above code?

Sorry i didnm't look too closely but i think you should only need to 
keep the file open andd then  loop around with a delay.
Sometjing like:

try:
  f = open('foo.txt')
  for line in f:
     print line
     time.sleep(1)
finally:
   f.close()

That will keep reading the lines until it hits the end of the file.
Of course if the file is eventually empty then it exits so you
may want a while True loop instead and only print if the line is non 
empty
In that case you need to figure out how to stop the loop - maybe 
Ctrl-C
is good enough.

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to