@@ -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
@@ -1088,18 +1093,18 @@ Glossary
1088
1093
sequence
1089
1094
An :term: `iterable ` which supports efficient element access using integer
1090
1095
indices via the :meth: `~object.__getitem__ ` special method and defines a
1091
- :meth: `__len__ ` method that returns the length of the sequence.
1096
+ :meth: `~object. __len__ ` method that returns the length of the sequence.
1092
1097
Some built-in sequence types are :class: `list `, :class: `str `,
1093
1098
:class: `tuple `, and :class: `bytes `. Note that :class: `dict ` also
1094
- supports :meth: `~object.__getitem__ ` and :meth: `__len__ `, but is considered a
1099
+ supports :meth: `~object.__getitem__ ` and :meth: `! __len__ `, but is considered a
1095
1100
mapping rather than a sequence because the lookups use arbitrary
1096
1101
:term: `immutable ` keys rather than integers.
1097
1102
1098
1103
The :class: `collections.abc.Sequence ` abstract base class
1099
1104
defines a much richer interface that goes beyond just
1100
- :meth: `~object.__getitem__ ` and :meth: `__len__ `, adding :meth: ` count `,
1101
- :meth: `index `, :meth: `__contains__ `, and
1102
- :meth: `__reversed__ `. Types that implement this expanded
1105
+ :meth: `~object.__getitem__ ` and :meth: `~object. __len__ `, adding
1106
+ :meth: `count `, :meth: ` index `, :meth: `~object. __contains__ `, and
1107
+ :meth: `~object. __reversed__ `. Types that implement this expanded
1103
1108
interface can be registered explicitly using
1104
1109
:func: `~abc.ABCMeta.register `.
1105
1110
0 commit comments