[issue20992] reading individual bytes of multiple binary files using the Python module fileinput

Josh Rosenberg report at bugs.python.org
Mon Mar 24 22:44:39 CET 2014


Josh Rosenberg added the comment:

fileinput's semantics are heavily tied to lines, not bytes. And processing binary files byte by byte is rather inefficient; can you explain why this feature would be of general utility such that it would be worth including it in the standard library?

It's not hard to just get a byte at a time using existing parts:

    def bytefileinput():
        return (bytes((b,)) for line in fileinput.input() for b in line)

There are ways to do similar things without using fileinput at all. But it really depends on your use case.

Giving fileinput a read() method isn't a bad idea assuming some reasonable behavior is defined for the various line oriented methods, but making it iterate binary mode input byte by byte would be a breaking change of limited utility in my view.

----------
nosy: +josh.rosenberg

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20992>
_______________________________________


More information about the Python-bugs-list mailing list