Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
>If you open the file in binary mode, you can easily keep track of the
>position in file:
>
>bytepos = 0
>with file(filename) as f:
>   for line in f:
>     ... process line ...
>     bytepos += len(line)
>
>If you need to restart the operation, simply seek to the previously
>known position:
>
># restart with old bytyepos
>with file(filename) as f:
>   f.seek(bytepos)
>   for line in f:
>     ... process line ...
>     bytepos += len(line)
>--

Thanks! This works perfectly. I did not know you can iterate directly using 
the file handle!

Karim

_________________________________________________________________
Windows Live Hotmail, with safety bar colour coding, helps identify 
suspicious mail before it takes your daughter out on a date. Upgrade today 
for a better look. www.newhotmail.ca?icid=WLHMENCA152

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to