| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -210,8 +210,8 @@ have to remember to change two places in your program -- the second occurrence | |||
| 210 | 210 | is hidden at the bottom of the loop. | |
| 211 | 211 | ||
| 212 | 212 | The best approach is to use iterators, making it possible to loop through | |
| 213 | - objects using the ``for`` statement. For example, in the current version of | ||
| 214 | - Python file objects support the iterator protocol, so you can now write simply:: | ||
| 213 | + objects using the ``for`` statement. For example, :term:`file objects | ||
| 214 | + <file object>` support the iterator protocol, so you can write simply:: | ||
| 215 | 215 | ||
| 216 | 216 | for line in f: | |
| 217 | 217 | ... # do something with line... | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,10 +40,10 @@ Module :mod:`aifc` defines the following function: | |||
| 40 | 40 | .. function:: open(file, mode=None) | |
| 41 | 41 | ||
| 42 | 42 | Open an AIFF or AIFF-C file and return an object instance with methods that are | |
| 43 | - described below. The argument *file* is either a string naming a file or a file | ||
| 44 | - object. *mode* must be ``'r'`` or ``'rb'`` when the file must be opened for | ||
| 45 | - reading, or ``'w'`` or ``'wb'`` when the file must be opened for writing. If | ||
| 46 | - omitted, ``file.mode`` is used if it exists, otherwise ``'rb'`` is used. When | ||
| 43 | + described below. The argument *file* is either a string naming a file or a | ||
| 44 | + :term:`file object`. *mode* must be ``'r'`` or ``'rb'`` when the file must be | ||
| 45 | + opened for reading, or ``'w'`` or ``'wb'`` when the file must be opened for writing. | ||
| 46 | + If omitted, ``file.mode`` is used if it exists, otherwise ``'rb'`` is used. When | ||
| 47 | 47 | used for writing, the file object should be seekable, unless you know ahead of | |
| 48 | 48 | time how many samples you are going to write in total and use | |
| 49 | 49 | :meth:`writeframesraw` and :meth:`setnframes`. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -147,11 +147,11 @@ The following data items and methods are also supported: | |||
| 147 | 147 | ||
| 148 | 148 | .. method:: array.fromfile(f, n) | |
| 149 | 149 | ||
| 150 | - Read *n* items (as machine values) from the file object *f* and append them to | ||
| 151 | - the end of the array. If less than *n* items are available, :exc:`EOFError` is | ||
| 152 | - raised, but the items that were available are still inserted into the array. | ||
| 153 | - *f* must be a real built-in file object; something else with a :meth:`read` | ||
| 154 | - method won't do. | ||
| 150 | + Read *n* items (as machine values) from the :term:`file object` *f* and append | ||
| 151 | + them to the end of the array. If less than *n* items are available, | ||
| 152 | + :exc:`EOFError` is raised, but the items that were available are still | ||
| 153 | + inserted into the array. *f* must be a real built-in file object; something | ||
| 154 | + else with a :meth:`read` method won't do. | ||
| 155 | 155 | ||
| 156 | 156 | ||
| 157 | 157 | .. method:: array.fromlist(list) | |
@@ -214,7 +214,7 @@ The following data items and methods are also supported: | |||
| 214 | 214 | ||
| 215 | 215 | .. method:: array.tofile(f) | |
| 216 | 216 | ||
| 217 | - Write all items (as machine values) to the file object *f*. | ||
| 217 | + Write all items (as machine values) to the :term:`file object` *f*. | ||
| 218 | 218 | ||
| 219 | 219 | ||
| 220 | 220 | .. method:: array.tolist() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -225,9 +225,9 @@ any that have been added to the map during asynchronous service) is closed. | |||
| 225 | 225 | ||
| 226 | 226 | .. class:: file_dispatcher() | |
| 227 | 227 | ||
| 228 | - A file_dispatcher takes a file descriptor or file object along with an | ||
| 229 | - optional map argument and wraps it for use with the :cfunc:`poll` or | ||
| 230 | - :cfunc:`loop` functions. If provided a file object or anything with a | ||
| 228 | + A file_dispatcher takes a file descriptor or :term:`file object` along | ||
| 229 | + with an optional map argument and wraps it for use with the :cfunc:`poll` | ||
| 230 | + or :cfunc:`loop` functions. If provided a file object or anything with a | ||
| 231 | 231 | :cfunc:`fileno` method, that method will be called and passed to the | |
| 232 | 232 | :class:`file_wrapper` constructor. Availability: UNIX. | |
| 233 | 233 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -122,9 +122,9 @@ The legacy interface: | |||
| 122 | 122 | .. function:: decode(input, output) | |
| 123 | 123 | ||
| 124 | 124 | Decode the contents of the binary *input* file and write the resulting binary | |
| 125 | - data to the *output* file. *input* and *output* must either be file objects | ||
| 126 | - or objects that mimic the file object interface working with bytes | ||
| 127 | - objects. *input* will be read until ``input.read()`` returns an empty string. | ||
| 125 | + data to the *output* file. *input* and *output* must be :term:`file objects | ||
| 126 | + <file object>`. *input* will be read until ``input.read()`` returns an empty | ||
| 127 | + bytes object. | ||
| 128 | 128 | ||
| 129 | 129 | ||
| 130 | 130 | .. function:: decodebytes(s) | |
@@ -138,11 +138,10 @@ The legacy interface: | |||
| 138 | 138 | .. function:: encode(input, output) | |
| 139 | 139 | ||
| 140 | 140 | Encode the contents of the binary *input* file and write the resulting base64 | |
| 141 | - encoded data to the *output* file. *input* and *output* must either be file | ||
| 142 | - objects or objects that mimic the file object interface working with bytes | ||
| 143 | - objects. *input* will be read until ``input.read()`` returns an empty string. | ||
| 144 | - :func:`encode` returns the encoded data plus a trailing newline character | ||
| 145 | - (``b'\n'``). | ||
| 141 | + encoded data to the *output* file. *input* and *output* must be :term:`file | ||
| 142 | + objects <file object>`. *input* will be read until ``input.read()`` returns | ||
| 143 | + an empty bytes object. :func:`encode` returns the encoded data plus a trailing | ||
| 144 | + newline character (``b'\n'``). | ||
| 146 | 145 | ||
| 147 | 146 | ||
| 148 | 147 | .. function:: encodebytes(s) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,8 +25,8 @@ Here is a summary of the features offered by the bz2 module: | |||
| 25 | 25 | ||
| 26 | 26 | * :class:`BZ2File` class implements universal newline support; | |
| 27 | 27 | ||
| 28 | - * :class:`BZ2File` class offers an optimized line iteration using the readahead | ||
| 29 | - algorithm borrowed from file objects; | ||
| 28 | + * :class:`BZ2File` class offers an optimized line iteration using a readahead | ||
| 29 | + algorithm; | ||
| 30 | 30 | ||
| 31 | 31 | * Sequential (de)compression supported by :class:`BZ2Compressor` and | |
| 32 | 32 | :class:`BZ2Decompressor` classes; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -422,7 +422,7 @@ RawConfigParser Objects | |||
| 422 | 422 | ||
| 423 | 423 | .. method:: RawConfigParser.write(fileobject, space_around_delimiters=True) | |
| 424 | 424 | ||
| 425 | - Write a representation of the configuration to the specified file object, | ||
| 425 | + Write a representation of the configuration to the specified :term:`file object`, | ||
| 426 | 426 | which must be opened in text mode (accepting strings). This representation | |
| 427 | 427 | can be parsed by a future :meth:`read` call. If ``space_around_delimiters`` | |
| 428 | 428 | is ``True`` (the default), delimiters between keys and values are surrounded | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,9 +50,9 @@ The :mod:`csv` module defines the following functions: | |||
| 50 | 50 | ||
| 51 | 51 | Return a reader object which will iterate over lines in the given *csvfile*. | |
| 52 | 52 | *csvfile* can be any object which supports the :term:`iterator` protocol and returns a | |
| 53 | - string each time its :meth:`!next` method is called --- file objects and list | ||
| 54 | - objects are both suitable. If *csvfile* is a file object, it should be opened | ||
| 55 | - with ``newline=''``. [#]_ An optional | ||
| 53 | + string each time its :meth:`!next` method is called --- :term:`file objects | ||
| 54 | + <file object>` and list objects are both suitable. If *csvfile* is a file object, | ||
| 55 | + it should be opened with ``newline=''``. [#]_ An optional | ||
| 56 | 56 | *dialect* parameter can be given which is used to define a set of parameters | |
| 57 | 57 | specific to a particular CSV dialect. It may be an instance of a subclass of | |
| 58 | 58 | the :class:`Dialect` class or one of the strings returned by the | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,9 +28,9 @@ Here are the public methods of the :class:`Generator` class, imported from the | |||
| 28 | 28 | ||
| 29 | 29 | .. class:: Generator(outfp, mangle_from_=True, maxheaderlen=78) | |
| 30 | 30 | ||
| 31 | - The constructor for the :class:`Generator` class takes a file-like object called | ||
| 32 | - *outfp* for an argument. *outfp* must support the :meth:`write` method and be | ||
| 33 | - usable as the output file for the :func:`print` function. | ||
| 31 | + The constructor for the :class:`Generator` class takes a :term:`file-like object` | ||
| 32 | + called *outfp* for an argument. *outfp* must support the :meth:`write` method | ||
| 33 | + and be usable as the output file for the :func:`print` function. | ||
| 34 | 34 | ||
| 35 | 35 | Optional *mangle_from_* is a flag that, when ``True``, puts a ``>`` character in | |
| 36 | 36 | front of any line in the body that starts exactly as ``From``, i.e. ``From`` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -154,9 +154,9 @@ in the top-level :mod:`email` package namespace. | |||
| 154 | 154 | ||
| 155 | 155 | .. function:: message_from_file(fp[, _class][, strict]) | |
| 156 | 156 | ||
| 157 | - Return a message object structure tree from an open file object. This is | ||
| 158 | - exactly equivalent to ``Parser().parse(fp)``. Optional *_class* and *strict* | ||
| 159 | - are interpreted as with the :class:`Parser` class constructor. | ||
| 157 | + Return a message object structure tree from an open :term:`file object`. | ||
| 158 | + This is exactly equivalent to ``Parser().parse(fp)``. Optional *_class* | ||
| 159 | + and *strict* are interpreted as with the :class:`Parser` class constructor. | ||
| 160 | 160 | ||
| 161 | 161 | Here's an example of how you might use this at an interactive Python prompt:: | |
| 162 | 162 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments