Re: EOFError with fileinput

2010-08-17 Thread Alex van der Spek
Thanks all! I understand better now. I had no idea that EOFError was an exception. I was looking for a function to tell me when the end of a sequential file is reached as in all of the 4 programming languages that I do know this is a requirement. Will modify my program accordingly. Alex van

EOFError with fileinput

2010-08-16 Thread Alex van der Spek
Using the fileinput module to process lists of files: for line in fileinput.input(logs): Unfortunately, EOFError does not seem to indicate the end-of-file condition correctly when using fileinput. How would you find the EOF file for all the files in the file list 'logs'? Thank you, Alex

Re: EOFError with fileinput

2010-08-16 Thread Mark Lawrence
On 16/08/2010 17:29, Alex van der Spek wrote: Using the fileinput module to process lists of files: for line in fileinput.input(logs): Unfortunately, EOFError does not seem to indicate the end-of-file condition correctly when using fileinput. How would you find the EOF file for all the

Re: EOFError with fileinput

2010-08-16 Thread Alex van der Spek
Here is an excerpt. It works because the end condition is a fixed number (ln==10255), the approximate number of data lines in a file. If I replace that condition by EOFError, the program does not do the intended work. It appears as if EOFError is always true in this case.

Re: EOFError with fileinput

2010-08-16 Thread Steven D'Aprano
On Mon, 16 Aug 2010 19:27:32 +0200, Alex van der Spek wrote: Here is an excerpt. It works because the end condition is a fixed number (ln==10255), the approximate number of data lines in a file. If I replace that condition by EOFError, the program does not do the intended work. It appears as