| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -160,9 +160,9 @@ Glossary | |||
| 160 | 160 | A :term:`file object` able to read and write | |
| 161 | 161 | :term:`bytes-like objects <bytes-like object>`. | |
| 162 | 162 | Examples of binary files are files opened in binary mode (``'rb'``, | |
| 163 | - ``'wb'`` or ``'rb+'``), :data:`sys.stdin.buffer`, | ||
| 164 | - :data:`sys.stdout.buffer`, and instances of :class:`io.BytesIO` and | ||
| 165 | - :class:`gzip.GzipFile`. | ||
| 163 | + ``'wb'`` or ``'rb+'``), :data:`sys.stdin.buffer <sys.stdin>`, | ||
| 164 | + :data:`sys.stdout.buffer <sys.stdout>`, and instances of | ||
| 165 | + :class:`io.BytesIO` and :class:`gzip.GzipFile`. | ||
| 166 | 166 | ||
| 167 | 167 | See also :term:`text file` for a file object able to read and write | |
| 168 | 168 | :class:`str` objects. | |
@@ -313,8 +313,9 @@ Glossary | |||
| 313 | 313 | :ref:`class definitions <class>` for more about decorators. | |
| 314 | 314 | ||
| 315 | 315 | descriptor | |
| 316 | - Any object which defines the methods :meth:`__get__`, :meth:`__set__`, or | ||
| 317 | - :meth:`__delete__`. When a class attribute is a descriptor, its special | ||
| 316 | + Any object which defines the methods :meth:`~object.__get__`, | ||
| 317 | + :meth:`~object.__set__`, or :meth:`~object.__delete__`. | ||
| 318 | + When a class attribute is a descriptor, its special | ||
| 318 | 319 | binding behavior is triggered upon attribute lookup. Normally, using | |
| 319 | 320 | *a.b* to get, set or delete an attribute looks up the object named *b* in | |
| 320 | 321 | the class dictionary for *a*, but if *b* is a descriptor, the respective | |
@@ -328,7 +329,8 @@ Glossary | |||
| 328 | 329 | ||
| 329 | 330 | dictionary | |
| 330 | 331 | An associative array, where arbitrary keys are mapped to values. The | |
| 331 | - keys can be any object with :meth:`__hash__` and :meth:`__eq__` methods. | ||
| 332 | + keys can be any object with :meth:`~object.__hash__` and | ||
| 333 | + :meth:`~object.__eq__` methods. | ||
| 332 | 334 | Called a hash in Perl. | |
| 333 | 335 | ||
| 334 | 336 | dictionary comprehension | |
@@ -392,7 +394,7 @@ Glossary | |||
| 392 | 394 | ||
| 393 | 395 | file object | |
| 394 | 396 | An object exposing a file-oriented API (with methods such as | |
| 395 | - :meth:`read()` or :meth:`write()`) to an underlying resource. Depending | ||
| 397 | + :meth:`!read` or :meth:`!write`) to an underlying resource. Depending | ||
| 396 | 398 | on the way it was created, a file object can mediate access to a real | |
| 397 | 399 | on-disk file or to another type of storage or communication device | |
| 398 | 400 | (for example standard input/output, in-memory buffers, sockets, pipes, | |
@@ -568,8 +570,9 @@ Glossary | |||
| 568 | 570 | ||
| 569 | 571 | hashable | |
| 570 | 572 | An object is *hashable* if it has a hash value which never changes during | |
| 571 | - its lifetime (it needs a :meth:`__hash__` method), and can be compared to | ||
| 572 | - other objects (it needs an :meth:`__eq__` method). Hashable objects which | ||
| 573 | + its lifetime (it needs a :meth:`~object.__hash__` method), and can be | ||
| 574 | + compared to other objects (it needs an :meth:`~object.__eq__` method). | ||
| 575 | + Hashable objects which | ||
| 573 | 576 | compare equal must have the same hash value. | |
| 574 | 577 | ||
| 575 | 578 | Hashability makes an object usable as a dictionary key and a set member, | |
@@ -645,7 +648,8 @@ Glossary | |||
| 645 | 648 | iterables include all sequence types (such as :class:`list`, :class:`str`, | |
| 646 | 649 | and :class:`tuple`) and some non-sequence types like :class:`dict`, | |
| 647 | 650 | :term:`file objects <file object>`, and objects of any classes you define | |
| 648 | - with an :meth:`__iter__` method or with a :meth:`~object.__getitem__` method | ||
| 651 | + with an :meth:`~iterator.__iter__` method or with a | ||
| 652 | + :meth:`~object.__getitem__` method | ||
| 649 | 653 | that implements :term:`sequence` semantics. | |
| 650 | 654 | ||
| 651 | 655 | Iterables can be | |
@@ -654,7 +658,7 @@ Glossary | |||
| 654 | 658 | as an argument to the built-in function :func:`iter`, it returns an | |
| 655 | 659 | iterator for the object. This iterator is good for one pass over the set | |
| 656 | 660 | of values. When using iterables, it is usually not necessary to call | |
| 657 | - :func:`iter` or deal with iterator objects yourself. The ``for`` | ||
| 661 | + :func:`iter` or deal with iterator objects yourself. The :keyword:`for` | ||
| 658 | 662 | statement does that automatically for you, creating a temporary unnamed | |
| 659 | 663 | variable to hold the iterator for the duration of the loop. See also | |
| 660 | 664 | :term:`iterator`, :term:`sequence`, and :term:`generator`. | |
@@ -665,8 +669,8 @@ Glossary | |||
| 665 | 669 | :func:`next`) return successive items in the stream. When no more data | |
| 666 | 670 | are available a :exc:`StopIteration` exception is raised instead. At this | |
| 667 | 671 | point, the iterator object is exhausted and any further calls to its | |
| 668 | - :meth:`__next__` method just raise :exc:`StopIteration` again. Iterators | ||
| 669 | - are required to have an :meth:`__iter__` method that returns the iterator | ||
| 672 | + :meth:`!__next__` method just raise :exc:`StopIteration` again. Iterators | ||
| 673 | + are required to have an :meth:`~iterator.__iter__` method that returns the iterator | ||
| 670 | 674 | object itself so every iterator is also iterable and may be used in most | |
| 671 | 675 | places where other iterables are accepted. One notable exception is code | |
| 672 | 676 | which attempts multiple iteration passes. A container object (such as a | |
@@ -680,7 +684,7 @@ Glossary | |||
| 680 | 684 | .. impl-detail:: | |
| 681 | 685 | ||
| 682 | 686 | CPython does not consistently apply the requirement that an iterator | |
| 683 | - define :meth:`__iter__`. | ||
| 687 | + define :meth:`~iterator.__iter__`. | ||
| 684 | 688 | ||
| 685 | 689 | key function | |
| 686 | 690 | A key function or collation function is a callable that returns a value | |
@@ -874,7 +878,8 @@ Glossary | |||
| 874 | 878 | Old name for the flavor of classes now used for all class objects. In | |
| 875 | 879 | earlier Python versions, only new-style classes could use Python's newer, | |
| 876 | 880 | versatile features like :attr:`~object.__slots__`, descriptors, | |
| 877 | - properties, :meth:`__getattribute__`, class methods, and static methods. | ||
| 881 | + properties, :meth:`~object.__getattribute__`, class methods, and static | ||
| 882 | + methods. | ||
| 878 | 883 | ||
| 879 | 884 | object | |
| 880 | 885 | Any data with state (attributes or value) and defined behavior | |
@@ -954,7 +959,7 @@ Glossary | |||
| 954 | 959 | finders implement. | |
| 955 | 960 | ||
| 956 | 961 | path entry hook | |
| 957 | - A callable on the :data:`sys.path_hook` list which returns a :term:`path | ||
| 962 | + A callable on the :data:`sys.path_hooks` list which returns a :term:`path | ||
| 958 | 963 | entry finder` if it knows how to find modules on a specific :term:`path | |
| 959 | 964 | entry`. | |
| 960 | 965 | ||
@@ -1086,18 +1091,18 @@ Glossary | |||
| 1086 | 1091 | sequence | |
| 1087 | 1092 | An :term:`iterable` which supports efficient element access using integer | |
| 1088 | 1093 | indices via the :meth:`~object.__getitem__` special method and defines a | |
| 1089 | - :meth:`__len__` method that returns the length of the sequence. | ||
| 1094 | + :meth:`~object.__len__` method that returns the length of the sequence. | ||
| 1090 | 1095 | Some built-in sequence types are :class:`list`, :class:`str`, | |
| 1091 | 1096 | :class:`tuple`, and :class:`bytes`. Note that :class:`dict` also | |
| 1092 | - supports :meth:`~object.__getitem__` and :meth:`__len__`, but is considered a | ||
| 1097 | + supports :meth:`~object.__getitem__` and :meth:`!__len__`, but is considered a | ||
| 1093 | 1098 | mapping rather than a sequence because the lookups use arbitrary | |
| 1094 | 1099 | :term:`immutable` keys rather than integers. | |
| 1095 | 1100 | ||
| 1096 | 1101 | The :class:`collections.abc.Sequence` abstract base class | |
| 1097 | 1102 | defines a much richer interface that goes beyond just | |
| 1098 | - :meth:`~object.__getitem__` and :meth:`__len__`, adding :meth:`count`, | ||
| 1099 | - :meth:`index`, :meth:`__contains__`, and | ||
| 1100 | - :meth:`__reversed__`. Types that implement this expanded | ||
| 1103 | + :meth:`~object.__getitem__` and :meth:`~object.__len__`, adding | ||
| 1104 | + :meth:`count`, :meth:`index`, :meth:`~object.__contains__`, and | ||
| 1105 | + :meth:`~object.__reversed__`. Types that implement this expanded | ||
| 1101 | 1106 | interface can be registered explicitly using | |
| 1102 | 1107 | :func:`~abc.ABCMeta.register`. | |
| 1103 | 1108 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,7 +44,8 @@ Any object can be tested for truth value, for use in an :keyword:`if` or | |||
| 44 | 44 | .. index:: single: true | |
| 45 | 45 | ||
| 46 | 46 | By default, an object is considered true unless its class defines either a | |
| 47 | - :meth:`~object.__bool__` method that returns ``False`` or a :meth:`__len__` method that | ||
| 47 | + :meth:`~object.__bool__` method that returns ``False`` or a | ||
| 48 | + :meth:`~object.__len__` method that | ||
| 48 | 49 | returns zero, when called with the object. [1]_ Here are most of the built-in | |
| 49 | 50 | objects considered false: | |
| 50 | 51 | ||
@@ -197,7 +198,7 @@ exception. | |||
| 197 | 198 | ||
| 198 | 199 | Two more operations with the same syntactic priority, :keyword:`in` and | |
| 199 | 200 | :keyword:`not in`, are supported by types that are :term:`iterable` or | |
| 200 | - implement the :meth:`__contains__` method. | ||
| 201 | + implement the :meth:`~object.__contains__` method. | ||
| 201 | 202 | ||
| 202 | 203 | .. _typesnumeric: | |
| 203 | 204 | ||
@@ -711,7 +712,7 @@ that's defined for any rational number, and hence applies to all instances of | |||
| 711 | 712 | :class:`int` and :class:`fractions.Fraction`, and all finite instances of | |
| 712 | 713 | :class:`float` and :class:`decimal.Decimal`. Essentially, this function is | |
| 713 | 714 | given by reduction modulo ``P`` for a fixed prime ``P``. The value of ``P`` is | |
| 714 | - made available to Python as the :attr:`modulus` attribute of | ||
| 715 | + made available to Python as the :attr:`~sys.hash_info.modulus` attribute of | ||
| 715 | 716 | :data:`sys.hash_info`. | |
| 716 | 717 | ||
| 717 | 718 | .. impl-detail:: | |
@@ -866,9 +867,9 @@ Generator Types | |||
| 866 | 867 | --------------- | |
| 867 | 868 | ||
| 868 | 869 | Python's :term:`generator`\s provide a convenient way to implement the iterator | |
| 869 | - protocol. If a container object's :meth:`__iter__` method is implemented as a | ||
| 870 | + protocol. If a container object's :meth:`~iterator.__iter__` method is implemented as a | ||
| 870 | 871 | generator, it will automatically return an iterator object (technically, a | |
| 871 | - generator object) supplying the :meth:`__iter__` and :meth:`~generator.__next__` | ||
| 872 | + generator object) supplying the :meth:`!__iter__` and :meth:`~generator.__next__` | ||
| 872 | 873 | methods. | |
| 873 | 874 | More information about generators can be found in :ref:`the documentation for | |
| 874 | 875 | the yield expression <yieldexpr>`. | |
@@ -3624,7 +3625,7 @@ The conversion types are: | |||
| 3624 | 3625 | +------------+-----------------------------------------------------+-------+ | |
| 3625 | 3626 | | ``'b'`` | Bytes (any object that follows the | \(5) | | |
| 3626 | 3627 | | | :ref:`buffer protocol <bufferobjects>` or has | | | |
| 3627 | - | | :meth:`__bytes__`). | | | ||
| 3628 | + | | :meth:`~object.__bytes__`). | | | ||
| 3628 | 3629 | +------------+-----------------------------------------------------+-------+ | |
| 3629 | 3630 | | ``'s'`` | ``'s'`` is an alias for ``'b'`` and should only | \(6) | | |
| 3630 | 3631 | | | be used for Python2/3 code bases. | | | |
@@ -4359,7 +4360,8 @@ The constructors for both classes work the same: | |||
| 4359 | 4360 | :meth:`symmetric_difference_update` methods will accept any iterable as an | |
| 4360 | 4361 | argument. | |
| 4361 | 4362 | ||
| 4362 | - Note, the *elem* argument to the :meth:`__contains__`, :meth:`remove`, and | ||
| 4363 | + Note, the *elem* argument to the :meth:`~object.__contains__`, | ||
| 4364 | + :meth:`remove`, and | ||
| 4363 | 4365 | :meth:`discard` methods may be a set. To support searching for an equivalent | |
| 4364 | 4366 | frozenset, a temporary one is created from *elem*. | |
| 4365 | 4367 | ||
@@ -5178,9 +5180,11 @@ instantiated from the type:: | |||
| 5178 | 5180 | TypeError: cannot create 'types.UnionType' instances | |
| 5179 | 5181 | ||
| 5180 | 5182 | .. note:: | |
| 5181 | - The :meth:`__or__` method for type objects was added to support the syntax | ||
| 5182 | - ``X | Y``. If a metaclass implements :meth:`__or__`, the Union may | ||
| 5183 | - override it:: | ||
| 5183 | + The :meth:`!__or__` method for type objects was added to support the syntax | ||
| 5184 | + ``X | Y``. If a metaclass implements :meth:`!__or__`, the Union may | ||
| 5185 | + override it: | ||
| 5186 | + | ||
| 5187 | + .. doctest:: | ||
| 5184 | 5188 | ||
| 5185 | 5189 | >>> class M(type): | |
| 5186 | 5190 | ... def __or__(self, other): | |
@@ -5192,7 +5196,7 @@ instantiated from the type:: | |||
| 5192 | 5196 | >>> C | int | |
| 5193 | 5197 | 'Hello' | |
| 5194 | 5198 | >>> int | C | |
| 5195 | - int | __main__.C | ||
| 5199 | + int | C | ||
| 5196 | 5200 | ||
| 5197 | 5201 | .. seealso:: | |
| 5198 | 5202 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments