I'd like to be able to read binary data from stdin with python.
However, when I use input = sys.stdin.buffer.read()
, I get the error that AttributeError: 'file' object has no attribute 'buffer'
. This seems strange because the docs say that I should be able to use the underlying buffer object - how can I fix / work around this?
Notes: I've checked out the last time this was asked, but the answers there are all either "use -u", "use buffer" (which I'm trying), or something about reading from files. The first and last don't help because I have no control over the users of this program (so I can't tell them to use particular arguments) and because this is stdin - not files.