On 19.07.2014 09:10, Nick Coghlan wrote:
I still favour my proposal there to add a separate "readrecords()" method, rather than reusing the line based iteration methods - lines and arbitrary records *aren't* the same thing, and I don't think we'd be doing anybody any favours by conflating them (whether we're confusing them at the method level or at the constructor argument level).
Thinking about possible use-cases for my own work, made me realize one thing: At least for text files, the distinction between records and lines, in practical terms, is that records may have *internal structure based on newline characters*, while lines are just lines. If a future readrecords() method would return the record as a StringIO or BytesIO object, this would allow nested reading of files as lines (with full newline processing) within records: for record in infile.readrecords(): for line in record: do_something() For me, that sort of feature is a more common requirement than being able to retrieve single lines terminated by something else than newline characters. Maybe though, it's possible to have both, a readrecords method like the one above and an extended set of "newline" tokens that can be passed to open (at least allowing "\0" seems to make sense). Best, Wolfgang