Re: Reading a file and resuming reading.

2007-05-26 Thread Hendrik van Rooyen
"Karim Ali" wrote: > Hi, > > Simple question. Is it possible in python to write code of the type: > > - > while not eof <- really want the EOF and not just an empty line! readline() reads to the next newline - an empty line *is* EOF - a blank line has at least a

Re: Reading a file and resuming reading.

2007-05-25 Thread Karim Ali
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

Re: Reading a file and resuming reading.

2007-05-25 Thread Hrvoje Niksic
"Karim Ali" <[EMAIL PROTECTED]> writes: > - > while not eof <- really want the EOF and not just an empty line! > readline by line > end while; > - for line in open_file: ... It will stop on EOF, not on empty line. > But also, in cas

Re: Reading a file and resuming reading.

2007-05-25 Thread Laszlo Nagy
Karim Ali wrote: > Hi, > > Simple question. Is it possible in python to write code of the type: > > - > while not eof <- really want the EOF and not just an empty line! > readline by line > end while; > - > > What I am using now is the im

Re: Reading a file and resuming reading.

2007-05-25 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Karim Ali wrote: > Simple question. Is it possible in python to write code of the type: > > - > while not eof <- really want the EOF and not just an empty line! > readline by line > end while; > - while True: