7stud wrote: > On Apr 13, 6:20 am, Michael Hoffman <[EMAIL PROTECTED]> wrote: [...] > > But if you hit return on a blank line, there is no error. In other > words, will stop on a blank line and not return EOFError. > > Anyway, it seems everyone is saying that when you iterate over a file, > the whole file is first read into memory. Therefore iterating over > sys.stdin is consistent: you have to type Ctrl+D to signal EOF before > the iteration can start. Is that about right? > No. The file content is usually buffered, but the buffering doesn't necessarily include the whole content of the file.
If you are iterating over the file the correct way to access the next line is to call the file's .next() method, as I indicated before. If you are reading lines the appropriate way is to use readline(). And, as you have already seen an error message telling you, mixing the two types is unlikely to give you usable results. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list