#15694: Link discussion of file objects to glossary entry.

This is analogous to the link for `flie objects` in the description of
'open' that exists in the 2.7 docs, and adds a similar link to the
io docs.

Patch by Chris Jerdonek.
This commit is contained in:
R David Murray 2012-08-17 20:33:54 -04:00
parent f6190c1463
commit 9f0c9401d3
2 changed files with 16 additions and 8 deletions

View File

@ -790,10 +790,13 @@ are always available. They are listed here in alphabetical order.
:meth:`__index__` method that returns an integer. :meth:`__index__` method that returns an integer.
.. index::
single: file object; open() built-in function
.. function:: open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True) .. function:: open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True)
Open *file* and return a corresponding stream. If the file cannot be opened, Open *file* and return a corresponding :term:`file object`. If the file
an :exc:`IOError` is raised. cannot be opened, an :exc:`IOError` is raised.
*file* is either a string or bytes object giving the pathname (absolute or *file* is either a string or bytes object giving the pathname (absolute or
relative to the current working directory) of the file to be opened or relative to the current working directory) of the file to be opened or
@ -900,7 +903,8 @@ are always available. They are listed here in alphabetical order.
closed. If a filename is given *closefd* has no effect and must be ``True`` closed. If a filename is given *closefd* has no effect and must be ``True``
(the default). (the default).
The type of file object returned by the :func:`open` function depends on the The type of :term:`file object` returned by the :func:`open` function
depends on the
mode. When :func:`open` is used to open a file in a text mode (``'w'``, mode. When :func:`open` is used to open a file in a text mode (``'w'``,
``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a subclass of ``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a subclass of
:class:`io.TextIOBase` (specifically :class:`io.TextIOWrapper`). When used :class:`io.TextIOBase` (specifically :class:`io.TextIOWrapper`). When used

View File

@ -16,11 +16,15 @@
Overview Overview
-------- --------
The :mod:`io` module provides Python's main facilities for dealing for various .. index::
types of I/O. There are three main types of I/O: *text I/O*, *binary I/O*, *raw single: file object; io module
I/O*. These are generic categories, and various backing stores can be used for
each of them. Concrete objects belonging to any of these categories will often The :mod:`io` module provides Python's main facilities for dealing with various
be called *streams*; another common term is *file-like objects*. types of I/O. There are three main types of I/O: *text I/O*, *binary I/O*
and *raw I/O*. These are generic categories, and various backing stores can
be used for each of them. A concrete object belonging to any of these
categories is called a :term:`file object`. Other common terms are *stream*
and *file-like object*.
Independently of its category, each concrete stream object will also have Independently of its category, each concrete stream object will also have
various capabilities: it can be read-only, write-only, or read-write. It can various capabilities: it can be read-only, write-only, or read-write. It can