BIG problem if readline strips newlines
wjdandreta at worldnet.att.net
Tue Jun 12 14:28:51 EDT 2001
>i've seen frequent mention of an option for readline()
>to strip out newlines as each string is read. this sounds
>like a great idea, but i realized its gonna be very
>difficult to loop through a text file. the standard
>python idioms will no longer work...
I don't think it means it changes the file, just the string(s) that are
returned by readline(s)(). Blank lines will be empty strings.
a file like:
for lines = file.readlines(chomp=1)
lines will be: ['hello','','test'] instead of the normal
The file will not be altered.
More information about the Python-list