Reading in cooked mode

Marko Rauhamaa marko at pacujo.net
Sun Mar 23 06:22:11 EDT 2014


Cameron Simpson <cs at zip.com.au>:

> Plenty of people use editors that consider end-of-line to be a
> separator and not a terminator, leading to supposed text files lacking
> trailing newlines (or end-of-line of OS).

I use an editor (emacs) that considers the end-of-line to be a byte
among others.

> I consider this sloppy and error prone.

If any editor, emacs is smart, but it generally doesn't insert
characters on its own. I like it that way.

> So I'm happy to write code that errors if a line lacks a trailing
> newline, and thus I consider the newline to be an intergral part of
> the line.

For sure, any file reader must think the situation through. Note, for
example, that CPython doesn't require the source code file to end in a
newline.


Marko



More information about the Python-list mailing list