[Python-ideas] Iterating non-newline-separated files should be easier

Paul Moore p.f.moore at gmail.com
Sun Jul 20 15:42:20 CEST 2014


On 20 July 2014 12:53, Andrew Barnert <abarnert at yahoo.com.dmarc.invalid> wrote:
> There are some better examples you could have raised, however. For example, a bz2.BzipFile is created
> with bz2.open. And, while the file delegates to a BufferedReader or TextIOWrapper, bz2.open almost
> certainly validates its inputs and won't pass newline on to the BufferedReader in binary mode.
> So, it would have to be changed to get the benefit.

The most significant example is one which has been mentioned, but you
may have missed. The motivation for this proposal is to interoperate
with the -0 flag on things like the unix find command. But that is
typically used in a pipe, which means your Python program will likely
receive \0 terminated records via sys.stdin. And sys.stdin is already
opened for you - you do not have the option to specify a newline
argument.

In actual fact, I can't think of a good example (either from my own
experience, or mentioned in this thread) where I'd expect to be
reading \0-terminated records from anything *except* sys.stdin.

Paul


More information about the Python-ideas mailing list