[Python-3000] Lines breaking
alexandre at peadrop.com
Tue May 29 19:29:52 CEST 2007
I just thought about something. Would making readline(s) not glob the
line breaking character be a too radical idea? I think that is what
most people are expecting from a readline function, anyway. I often
see things like [line.strip() for line in open(file).readlines()],
which is not so elegant IMHO.
This should be accompanied with a change to writelines that would make
it appends to each line the platform-specific line breaking character,
as defined by os.linesep.
The main objections I would against the change is obviously breaking
backward-compatibility, and losing the closure property of
readlines/writelines -- i.e., after g.writelines(f.readlines()), g
wouldn't have the guarantee to have the same content of f. On the
other hand, this could give Python a neat way to convert line breaking
Anyway, that was just a random thought. I don't think the change is
worthwhile enough, to break backward-compatibility.
More information about the Python-3000