Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Side by Side Diff: Doc/library/fileinput.rst

Issue 18758: Fix internal references in the documentation
Patch Set: Created 6 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/library/exceptions.rst ('k') | Doc/library/ftplib.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`fileinput` --- Iterate over lines from multiple input streams 1 :mod:`fileinput` --- Iterate over lines from multiple input streams
2 =================================================================== 2 ===================================================================
3 3
4 .. module:: fileinput 4 .. module:: fileinput
5 :synopsis: Loop over standard input or a list of files. 5 :synopsis: Loop over standard input or a list of files.
6 .. moduleauthor:: Guido van Rossum <guido@python.org> 6 .. moduleauthor:: Guido van Rossum <guido@python.org>
7 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org> 7 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
8 8
9 **Source code:** :source:`Lib/fileinput.py` 9 **Source code:** :source:`Lib/fileinput.py`
10 10
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 The class which implements the sequence behavior provided by the module is 131 The class which implements the sequence behavior provided by the module is
132 available for subclassing as well: 132 available for subclassing as well:
133 133
134 134
135 .. class:: FileInput(files=None, inplace=False, backup='', bufsize=0, mode='r', openhook=None) 135 .. class:: FileInput(files=None, inplace=False, backup='', bufsize=0, mode='r', openhook=None)
136 136
137 Class :class:`FileInput` is the implementation; its methods :meth:`filename`, 137 Class :class:`FileInput` is the implementation; its methods :meth:`filename`,
138 :meth:`fileno`, :meth:`lineno`, :meth:`filelineno`, :meth:`isfirstline`, 138 :meth:`fileno`, :meth:`lineno`, :meth:`filelineno`, :meth:`isfirstline`,
139 :meth:`isstdin`, :meth:`nextfile` and :meth:`close` correspond to the functio ns 139 :meth:`isstdin`, :meth:`nextfile` and :meth:`close` correspond to the functio ns
140 of the same name in the module. In addition it has a :meth:`readline` method 140 of the same name in the module. In addition it has a :meth:`~io.TextIOBase.re adline` method
141 which returns the next input line, and a :meth:`__getitem__` method which 141 which returns the next input line, and a :meth:`__getitem__` method which
142 implements the sequence behavior. The sequence must be accessed in strictly 142 implements the sequence behavior. The sequence must be accessed in strictly
143 sequential order; random access and :meth:`readline` cannot be mixed. 143 sequential order; random access and :meth:`~io.TextIOBase.readline` cannot be mixed.
144 144
145 With *mode* you can specify which file mode will be passed to :func:`open`. I t 145 With *mode* you can specify which file mode will be passed to :func:`open`. I t
146 must be one of ``'r'``, ``'rU'``, ``'U'`` and ``'rb'``. 146 must be one of ``'r'``, ``'rU'``, ``'U'`` and ``'rb'``.
147 147
148 The *openhook*, when given, must be a function that takes two arguments, 148 The *openhook*, when given, must be a function that takes two arguments,
149 *filename* and *mode*, and returns an accordingly opened file-like object. Yo u 149 *filename* and *mode*, and returns an accordingly opened file-like object. Yo u
150 cannot use *inplace* and *openhook* together. 150 cannot use *inplace* and *openhook* together.
151 151
152 A :class:`FileInput` instance can be used as a context manager in the 152 A :class:`FileInput` instance can be used as a context manager in the
153 :keyword:`with` statement. In this example, *input* is closed after the 153 :keyword:`with` statement. In this example, *input* is closed after the
(...skipping 30 matching lines...) Expand all
184 Usage example: ``fi = fileinput.FileInput(openhook=fileinput.hook_compressed )`` 184 Usage example: ``fi = fileinput.FileInput(openhook=fileinput.hook_compressed )``
185 185
186 186
187 .. function:: hook_encoded(encoding) 187 .. function:: hook_encoded(encoding)
188 188
189 Returns a hook which opens each file with :func:`codecs.open`, using the give n 189 Returns a hook which opens each file with :func:`codecs.open`, using the give n
190 *encoding* to read the file. 190 *encoding* to read the file.
191 191
192 Usage example: ``fi = 192 Usage example: ``fi =
193 fileinput.FileInput(openhook=fileinput.hook_encoded("iso-8859-1"))`` 193 fileinput.FileInput(openhook=fileinput.hook_encoded("iso-8859-1"))``
OLDNEW
« no previous file with comments | « Doc/library/exceptions.rst ('k') | Doc/library/ftplib.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+