On Tue, Nov 3, 2015 at 9:56 AM, Tim Chase <python.l...@tim.thechases.com> wrote: > On 2015-11-03 16:35, Peter Otten wrote: >> I wish there were a way to prohibit such files. Maybe a special >> value >> >> with open(..., newline="normalize") f: >> assert all(line.endswith("\n") for line in f) >> >> to ensure that all lines end with "\n"? > > Or even more valuable to me: > > with open(..., newline="strip") as f: > assert all(not line.endswith(("\n", "\r")) for line in f) > > because I have countless loops that look something like > > with open(...) as f: > for line in f: > line = line.rstrip('\r\n') > process(line)
What would happen if you read a file opened like this without iterating over lines? -- https://mail.python.org/mailman/listinfo/python-list