Question: I'm trying to find a nice way to read a log file in real time using python. I'd like to process lines from a log file one at a time as it is written. Somehow I need to keep trying to read the file until it is created and then continue to process lines until I terminate the process. Is there an appropriate way to do this? Thanks.

Answer: 
You could try with something like this:

```
import time

while 1:
    where = file.tell()
    line = file.readline()
    if not line:
        time.sleep(1)
        file.seek(where)
    else:
        print line, # already has newline

```

Example was extracted from [here](http://code.activestate.com/recipes/157035-tail-f-in-python/).
Maybe you could do a system call to

```
tail -f

```

using os.system()