<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Daniel Mueller wrote:
<blockquote cite="midcl86oo$2sf6$1@news.imp.ch" type="cite">Diez B.
Roggisch wrote:
  <br>
  <br>
  <blockquote type="cite">If you're only interested in the content if
the file has actually
    <br>
changed - thats a totally different animal,
    <br>
  </blockquote>
  <br>
Good to hear! i only need the changes! do you have code examples?
  <br>
  <br>
  <blockquote type="cite">and is under unix doable using
    <br>
stat-calls (somewhere in the os module). I'm not sure how much that
extends
    <br>
to windows, but I'm pretty much confident that there is similar stuff
    <br>
available.
    <br>
  </blockquote>
  <br>
im programming under Linux
  <br>
  <br>
  <br>
  <br>
</blockquote>
You could do something like this.<br>
<br>
Here is something that is writing to a file:<br>
<br>
<font face="Courier New, Courier, monospace">In [5]: f =
open('/tmp/foobar.txt', 'w')<br>
<br>
In [6]: import time<br>
<br>
In [7]: for t in range(10):<br>
   ...:     f.write('this is entry %s\n' % t)<br>
   ...:     f.flush()<br>
   ...:     time.sleep(10)<br>
</font><br>
<br>
<br>
Here is something reading from the same file (with its output):<br>
<font face="Courier New, Courier, monospace"><br>
In [4]: import time<br>
<br>
In [5]: f = open('/tmp/foobar.txt', 'r')<br>
<br>
In [6]: for t in range(10):<br>
   ...:     print "read this from file: %s" % f.read()<br>
   ...:     time.sleep(10)<br>
   ...:<br>
read this from file: this is entry 0<br>
this is entry 1<br>
<br>
read this from file:<br>
read this from file: this is entry 2<br>
<br>
read this from file: this is entry 3<br>
<br>
read this from file: this is entry 4<br>
<br>
read this from file: this is entry 5<br>
<br>
read this from file: this is entry 6<br>
<br>
read this from file: this is entry 7<br>
<br>
read this from file: this is entry 8<br>
<br>
read this from file: this is entry 9</font><br>
<br>
<br>
If you open a file in read mode and don't close it, you can just keep
on giving the read() operation on it.  No need to close it and then
re-open it.  Although, if you did want/need to close it, you could
always store where the end of the file was when you last had it opened
as well as the last modification time and when you need to check the
file again, just stat it and if it has changed, open it, seek to the
former end, then start reading from there.....<br>
<br>
<br>
Jeremy Jones<br>
</body>
</html>