[RELEASED] Python 3.1 final

Paul Moore p.f.moore at gmail.com
Sun Jun 28 12:18:37 EDT 2009


2009/6/28 Christian Heimes <lists at cheimes.de>:
> Paul Moore schrieb:
>> I had a quick look at the documentation, and couldn't see how to do
>> this. It's the first time I'd read the new IO module documentation, so
>> I probably missed something obvious. Could you explain how I get the
>> byte stream underlying sys.stdin? (That should give me enough to find
>> what I was misunderstanding in the docs).
>
> You've missed the most obvious place to look for the feature -- the
> documentation of sys.stdin :)
>
> http://docs.python.org/3.0/library/sys.html#sys.stdin
>
>>>> import sys
>>>> sys.stdin
> <io.TextIOWrapper object at 0x7f65df915050>
>>>> sys.stdin.buffer
> <io.BufferedReader object at 0x7f65df90bdd0>
>>>> sys.stdin.read(1)
>
> '\n'
>>>> sys.stdin.buffer.read(1)

Thanks. Like you say, the obvious place I didn't think of... :-) (I'd
have experimented, but this PC doesn't have Python 3 installed at the
moment :-()

The "buffer" attribute doesn't seem to be documented in the docs for
the io module. I'm guessing that the TextIOBase class should have a
note that you get at the buffer through the "buffer" attribute?

Paul.



More information about the Python-list mailing list