Newbie: Reading textfiles
Steve Holden
sholden at bellatlantic.net
Wed Mar 1 12:44:11 EST 2000
More information about the Python-list mailing list
Wed Mar 1 12:44:11 EST 2000
- Previous message (by thread): I wasn't complaining! (Was: will python 3000 break my code?)
- Next message (by thread): Newbie: Reading textfiles
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The first call to readline() which returns an empty string indicates you have hit the end of the file. Empty lines in the file are returned as strings with the newline still in them. Don't forget that every line you actually read has the newline in it, too! Unless the files are too large to consider this, the readlines() file method is easier to use. But you've probably already rejected this by the way you state your question. regards Steve "Lutz Schröer" wrote: > > Hi, > > after looking for a"clever" solution for reading a text file line by line > from the beginning to the end for the whole day, I have to ask this > ridiculous newbie question: > > How do I read a textfile line by line and catch the eof? > > Latz -- "If computing ever stops being fun, I'll stop doing it"
- Previous message (by thread): I wasn't complaining! (Was: will python 3000 break my code?)
- Next message (by thread): Newbie: Reading textfiles
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list