Tim Chase 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)
Indeed. It's obvious now you're saying it... -- https://mail.python.org/mailman/listinfo/python-list