Where read() is documented

Chris Green cl at isbd.net
Sun Aug 30 04:04:35 EDT 2020


MRAB <python at mrabarnett.plus.com> wrote:
> On 2020-08-29 17:48, Chris Green wrote:
> > Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> >> Chris Green <cl at isbd.net> writes:    I can't find the documentation for
> >> >read().  It's not a built-in function and it's not documented with
> >> >(for example) the file type object sys.stdin.
> >> 
> >> |read() (asyncio.StreamReader method), 894
> >> |read() (chunk.Chunk method), 1385
> >> |read() (codecs.StreamReader method), 164
> >> |read() (configparser.ConfigParser method), 537
> >> |read() (http.client.HTTPResponse method), 1276
> >> |read() (imaplib.IMAP4 method), 1291
> >> |read() (in module os), 578
> >> |read() (io.BufferedIOBase method), 622
> >> |read() (io.BufferedReader method), 625
> >> |read() (io.RawIOBase method), 621
> >> |read() (io.TextIOBase method), 626
> >> |read() (mimetypes.MimeTypes method), 1146
> >> |read() (mmap.mmap method), 1053
> >> |read() (ossaudiodev.oss_audio_device method), 1388
> >> |read() (ssl.MemoryBIO method), 1024
> >> |read() (ssl.SSLSocket method), 1005
> >> |read() (urllib.robotparser.RobotFileParser method), 1268
> >> |read() (zipfile.ZipFile method), 499
> >> Index of "The Python Library Reference, Release 3.9.0a3"
> >> 
> >> 
> > But none of those is the documentation for read(), they're just places
> > that refer to read().
> > 
> There's no read() function. What you're referring to are the 'read' 
> methods of various classes.
> 
Yes, OK, method rather than function.


> If you open a file in text mode, you'll get an instance of 
> TextIOWrapper, which inherits .read from TextIOBase.
> 
> If you open a file in binary mode, you'll get an instance of 
> BufferedReader, which has a .read method.
> 
> Multiple classes, each with its own 'read' method.
> 
> sys.stdin is an instance of TextIOWrapper, so for that you should look 
> at the methods of TextIOWrapper.

I went to sys.stdin but it didn't really lead me easily to the read()
method.  All I actually wanted to know was what was the type of the
return value of the read() method which is different in Python 2 and 3.

-- 
Chris Green
·


More information about the Python-list mailing list