| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 24201d4 commit bfdcd43
40 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -634,7 +634,8 @@ Python 2.6 adds an :mod:`abc` module that lets you define Abstract Base Classes | |||
| 634 | 634 | (ABCs). You can then use :func:`isinstance` and :func:`issubclass` to check | |
| 635 | 635 | whether an instance or a class implements a particular ABC. The | |
| 636 | 636 | :mod:`collections.abc` module defines a set of useful ABCs such as | |
| 637 | - :class:`Iterable`, :class:`Container`, and :class:`MutableMapping`. | ||
| 637 | + :class:`~collections.abc.Iterable`, :class:`~collections.abc.Container`, and | ||
| 638 | + :class:`~collections.abc.MutableMapping`. | ||
| 638 | 639 | ||
| 639 | 640 | For Python, many of the advantages of interface specifications can be obtained | |
| 640 | 641 | by an appropriate test discipline for components. There is also a tool, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -531,9 +531,10 @@ The solution would be to use the low-level decoding interface to catch the case | |||
| 531 | 531 | of partial coding sequences. The work of implementing this has already been | |
| 532 | 532 | done for you: the built-in :func:`open` function can return a file-like object | |
| 533 | 533 | that assumes the file's contents are in a specified encoding and accepts Unicode | |
| 534 | - parameters for methods such as :meth:`read` and :meth:`write`. This works through | ||
| 535 | - :func:`open`\'s *encoding* and *errors* parameters which are interpreted just | ||
| 536 | - like those in :meth:`str.encode` and :meth:`bytes.decode`. | ||
| 534 | + parameters for methods such as :meth:`~io.TextIOBase.read` and | ||
| 535 | + :meth:`~io.TextIOBase.write`. This works through:func:`open`\'s *encoding* and | ||
| 536 | + *errors* parameters which are interpreted just like those in :meth:`str.encode` | ||
| 537 | + and :meth:`bytes.decode`. | ||
| 537 | 538 | ||
| 538 | 539 | Reading Unicode from a file is therefore simple:: | |
| 539 | 540 | ||
@@ -656,7 +657,8 @@ encodings, taking a stream that returns data in encoding #1 | |||
| 656 | 657 | and behaving like a stream returning data in encoding #2. | |
| 657 | 658 | ||
| 658 | 659 | For example, if you have an input file *f* that's in Latin-1, you | |
| 659 | - can wrap it with a :class:`StreamRecoder` to return bytes encoded in UTF-8:: | ||
| 660 | + can wrap it with a :class:`~codecs.StreamRecoder` to return bytes encoded in | ||
| 661 | + UTF-8:: | ||
| 660 | 662 | ||
| 661 | 663 | new_f = codecs.StreamRecoder(f, | |
| 662 | 664 | # en/decoder: used by read() to encode its results and | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,7 +57,7 @@ The simplest way to use urllib.request is as follows:: | |||
| 57 | 57 | html = response.read() | |
| 58 | 58 | ||
| 59 | 59 | If you wish to retrieve a resource via URL and store it in a temporary location, | |
| 60 | - you can do so via the :func:`urlretrieve` function:: | ||
| 60 | + you can do so via the :func:`~urllib.request.urlretrieve` function:: | ||
| 61 | 61 | ||
| 62 | 62 | import urllib.request | |
| 63 | 63 | local_filename, headers = urllib.request.urlretrieve('http://python.org/') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -290,11 +290,11 @@ and off individually. They are described here in more detail. | |||
| 290 | 290 | ||
| 291 | 291 | Converts the use of iterator's :meth:`~iterator.next` methods to the | |
| 292 | 292 | :func:`next` function. It also renames :meth:`next` methods to | |
| 293 | - :meth:`~object.__next__`. | ||
| 293 | + :meth:`~iterator.__next__`. | ||
| 294 | 294 | ||
| 295 | 295 | .. 2to3fixer:: nonzero | |
| 296 | 296 | ||
| 297 | - Renames :meth:`~object.__nonzero__` to :meth:`~object.__bool__`. | ||
| 297 | + Renames :meth:`__nonzero__` to :meth:`~object.__bool__`. | ||
| 298 | 298 | ||
| 299 | 299 | .. 2to3fixer:: numliterals | |
| 300 | 300 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -177,7 +177,7 @@ In addition to these methods, lock objects can also be used via the | |||
| 177 | 177 | equivalent to calling :func:`_thread.exit`. | |
| 178 | 178 | ||
| 179 | 179 | * Not all built-in functions that may block waiting for I/O allow other threads | |
| 180 | - to run. (The most popular ones (:func:`time.sleep`, :meth:`file.read`, | ||
| 180 | + to run. (The most popular ones (:func:`time.sleep`, :meth:`io.FileIO.read`, | ||
| 181 | 181 | :func:`select.select`) work as expected.) | |
| 182 | 182 | ||
| 183 | 183 | * It is not possible to interrupt the :meth:`acquire` method on a lock --- the | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -110,19 +110,19 @@ This module provides the following class: | |||
| 110 | 110 | MyIterable.register(Foo) | |
| 111 | 111 | ||
| 112 | 112 | The ABC ``MyIterable`` defines the standard iterable method, | |
| 113 | - :meth:`__iter__`, as an abstract method. The implementation given here can | ||
| 114 | - still be called from subclasses. The :meth:`get_iterator` method is also | ||
| 115 | - part of the ``MyIterable`` abstract base class, but it does not have to be | ||
| 116 | - overridden in non-abstract derived classes. | ||
| 113 | + :meth:`~iterator.__iter__`, as an abstract method. The implementation given | ||
| 114 | + here can still be called from subclasses. The :meth:`get_iterator` method | ||
| 115 | + is also part of the ``MyIterable`` abstract base class, but it does not have | ||
| 116 | + to be overridden in non-abstract derived classes. | ||
| 117 | 117 | ||
| 118 | 118 | The :meth:`__subclasshook__` class method defined here says that any class | |
| 119 | - that has an :meth:`__iter__` method in its :attr:`__dict__` (or in that of | ||
| 120 | - one of its base classes, accessed via the :attr:`__mro__` list) is | ||
| 121 | - considered a ``MyIterable`` too. | ||
| 119 | + that has an :meth:`~iterator.__iter__` method in its | ||
| 120 | + :attr:`~object.__dict__` (or in that of one of its base classes, accessed | ||
| 121 | + via the :attr:`~class.__mro__` list) is considered a ``MyIterable`` too. | ||
| 122 | 122 | ||
| 123 | 123 | Finally, the last line makes ``Foo`` a virtual subclass of ``MyIterable``, | |
| 124 | - even though it does not define an :meth:`__iter__` method (it uses the | ||
| 125 | - old-style iterable protocol, defined in terms of :meth:`__len__` and | ||
| 124 | + even though it does not define an :meth:`~iterator.__iter__` method (it uses | ||
| 125 | + the old-style iterable protocol, defined in terms of :meth:`__len__` and | ||
| 126 | 126 | :meth:`__getitem__`). Note that this will not make ``get_iterator`` | |
| 127 | 127 | available as a method of ``Foo``, so it is provided separately. | |
| 128 | 128 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,10 +53,10 @@ any that have been added to the map during asynchronous service) is closed. | |||
| 53 | 53 | channels have been closed. All arguments are optional. The *count* | |
| 54 | 54 | parameter defaults to None, resulting in the loop terminating only when all | |
| 55 | 55 | channels have been closed. The *timeout* argument sets the timeout | |
| 56 | - parameter for the appropriate :func:`select` or :func:`poll` call, measured | ||
| 57 | - in seconds; the default is 30 seconds. The *use_poll* parameter, if true, | ||
| 58 | - indicates that :func:`poll` should be used in preference to :func:`select` | ||
| 59 | - (the default is ``False``). | ||
| 56 | + parameter for the appropriate :func:`~select.select` or :func:`~select.poll` | ||
| 57 | + call, measured in seconds; the default is 30 seconds. The *use_poll* | ||
| 58 | + parameter, if true, indicates that :func:`~select.poll` should be used in | ||
| 59 | + preference to :func:`~select.select` (the default is ``False``). | ||
| 60 | 60 | ||
| 61 | 61 | The *map* parameter is a dictionary whose items are the channels to watch. | |
| 62 | 62 | As channels are closed they are deleted from their map. If *map* is | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -241,7 +241,7 @@ to be stateless (i.e. to be able to tolerate packet loss) you should not only | |||
| 241 | 241 | transmit the data but also the state. Note that you should send the *initial* | |
| 242 | 242 | state (the one you passed to :func:`lin2adpcm`) along to the decoder, not the | |
| 243 | 243 | final state (as returned by the coder). If you want to use | |
| 244 | - :func:`struct.struct` to store the state in binary you can code the first | ||
| 244 | + :class:`struct.Struct` to store the state in binary you can code the first | ||
| 245 | 245 | element (the predicted value) in 16 bits and the second (the delta index) in 8. | |
| 246 | 246 | ||
| 247 | 247 | The ADPCM coders have never been tried against other ADPCM coders, only against | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -272,10 +272,11 @@ For simple text calendars this module provides the following functions. | |||
| 272 | 272 | ||
| 273 | 273 | .. function:: timegm(tuple) | |
| 274 | 274 | ||
| 275 | - An unrelated but handy function that takes a time tuple such as returned by the | ||
| 276 | - :func:`gmtime` function in the :mod:`time` module, and returns the corresponding | ||
| 277 | - Unix timestamp value, assuming an epoch of 1970, and the POSIX encoding. In | ||
| 278 | - fact, :func:`time.gmtime` and :func:`timegm` are each others' inverse. | ||
| 275 | + An unrelated but handy function that takes a time tuple such as returned by | ||
| 276 | + the :func:`~time.gmtime` function in the :mod:`time` module, and returns the | ||
| 277 | + corresponding Unix timestamp value, assuming an epoch of 1970, and the POSIX | ||
| 278 | + encoding. In fact, :func:`time.gmtime` and :func:`timegm` are each others' | ||
| 279 | + inverse. | ||
| 279 | 280 | ||
| 280 | 281 | ||
| 281 | 282 | The :mod:`calendar` module exports the following data attributes: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,8 +54,9 @@ instance will fail with a :exc:`EOFError` exception. | |||
| 54 | 54 | ||
| 55 | 55 | Class which represents a chunk. The *file* argument is expected to be a | |
| 56 | 56 | file-like object. An instance of this class is specifically allowed. The | |
| 57 | - only method that is needed is :meth:`read`. If the methods :meth:`seek` and | ||
| 58 | - :meth:`tell` are present and don't raise an exception, they are also used. | ||
| 57 | + only method that is needed is :meth:`~io.IOBase.read`. If the methods | ||
| 58 | + :meth:`~io.IOBase.seek` and :meth:`~io.IOBase.tell` are present and don't | ||
| 59 | + raise an exception, they are also used. | ||
| 59 | 60 | If these methods are present and raise an exception, they are expected to not | |
| 60 | 61 | have altered the object. If the optional argument *align* is true, chunks | |
| 61 | 62 | are assumed to be aligned on 2-byte boundaries. If *align* is false, no | |
| Back | FazBrowse Home | New Git URL |
0 commit comments