@@ -151,9 +151,9 @@ Glossary
151
151
A :term: `file object ` able to read and write
152
152
:term: `bytes-like objects <bytes-like object> `.
153
153
Examples of binary files are files opened in binary mode (``'rb' ``,
154
- ``'wb' `` or ``'rb+' ``), :data: `sys.stdin.buffer `,
155
- :data: `sys.stdout.buffer `, and instances of :class: ` io.BytesIO ` and
156
- :class: `gzip.GzipFile `.
154
+ ``'wb' `` or ``'rb+' ``), :data: `sys.stdin.buffer <sys.stdin> `,
155
+ :data: `sys.stdout.buffer <sys.stdout> `, and instances of
156
+ :class: `io.BytesIO ` and :class: ` gzip.GzipFile `.
157
157
158
158
See also :term: `text file ` for a file object able to read and write
159
159
:class: `str ` objects.
@@ -304,8 +304,9 @@ Glossary
304
304
:ref: `class definitions <class >` for more about decorators.
305
305
306
306
descriptor
307
- Any object which defines the methods :meth: `__get__ `, :meth: `__set__ `, or
308
- :meth: `__delete__ `. When a class attribute is a descriptor, its special
307
+ Any object which defines the methods :meth: `~object.__get__ `,
308
+ :meth: `~object.__set__ `, or :meth: `~object.__delete__ `.
309
+ When a class attribute is a descriptor, its special
309
310
binding behavior is triggered upon attribute lookup. Normally, using
310
311
*a.b * to get, set or delete an attribute looks up the object named *b * in
311
312
the class dictionary for *a *, but if *b * is a descriptor, the respective
@@ -319,7 +320,8 @@ Glossary
319
320
320
321
dictionary
321
322
An associative array, where arbitrary keys are mapped to values. The
322
- keys can be any object with :meth: `__hash__ ` and :meth: `__eq__ ` methods.
323
+ keys can be any object with :meth: `~object.__hash__ ` and
324
+ :meth: `~object.__eq__ ` methods.
323
325
Called a hash in Perl.
324
326
325
327
dictionary comprehension
@@ -383,7 +385,7 @@ Glossary
383
385
384
386
file object
385
387
An object exposing a file-oriented API (with methods such as
386
- :meth: `read() ` or :meth: `write() `) to an underlying resource. Depending
388
+ :meth: `! read ` or :meth: `! write `) to an underlying resource. Depending
387
389
on the way it was created, a file object can mediate access to a real
388
390
on-disk file or to another type of storage or communication device
389
391
(for example standard input/output, in-memory buffers, sockets, pipes,
@@ -559,8 +561,9 @@ Glossary
559
561
560
562
hashable
561
563
An object is *hashable * if it has a hash value which never changes during
562
- its lifetime (it needs a :meth: `__hash__ ` method), and can be compared to
563
- other objects (it needs an :meth: `__eq__ ` method). Hashable objects which
564
+ its lifetime (it needs a :meth: `~object.__hash__ ` method), and can be
565
+ compared to other objects (it needs an :meth: `~object.__eq__ ` method).
566
+ Hashable objects which
564
567
compare equal must have the same hash value.
565
568
566
569
Hashability makes an object usable as a dictionary key and a set member,
@@ -646,7 +649,8 @@ Glossary
646
649
iterables include all sequence types (such as :class: `list `, :class: `str `,
647
650
and :class: `tuple `) and some non-sequence types like :class: `dict `,
648
651
:term: `file objects <file object> `, and objects of any classes you define
649
- with an :meth: `__iter__ ` method or with a :meth: `~object.__getitem__ ` method
652
+ with an :meth: `~iterator.__iter__ ` method or with a
653
+ :meth: `~object.__getitem__ ` method
650
654
that implements :term: `sequence ` semantics.
651
655
652
656
Iterables can be
@@ -655,7 +659,7 @@ Glossary
655
659
as an argument to the built-in function :func: `iter `, it returns an
656
660
iterator for the object. This iterator is good for one pass over the set
657
661
of values. When using iterables, it is usually not necessary to call
658
- :func: `iter ` or deal with iterator objects yourself. The `` for ` `
662
+ :func: `iter ` or deal with iterator objects yourself. The :keyword: ` for `
659
663
statement does that automatically for you, creating a temporary unnamed
660
664
variable to hold the iterator for the duration of the loop. See also
661
665
:term: `iterator `, :term: `sequence `, and :term: `generator `.
@@ -666,8 +670,8 @@ Glossary
666
670
:func: `next `) return successive items in the stream. When no more data
667
671
are available a :exc: `StopIteration ` exception is raised instead. At this
668
672
point, the iterator object is exhausted and any further calls to its
669
- :meth: `__next__ ` method just raise :exc: `StopIteration ` again. Iterators
670
- are required to have an :meth: `__iter__ ` method that returns the iterator
673
+ :meth: `! __next__ ` method just raise :exc: `StopIteration ` again. Iterators
674
+ are required to have an :meth: `~iterator. __iter__ ` method that returns the iterator
671
675
object itself so every iterator is also iterable and may be used in most
672
676
places where other iterables are accepted. One notable exception is code
673
677
which attempts multiple iteration passes. A container object (such as a
@@ -681,7 +685,7 @@ Glossary
681
685
.. impl-detail ::
682
686
683
687
CPython does not consistently apply the requirement that an iterator
684
- define :meth: `__iter__ `.
688
+ define :meth: `~iterator. __iter__ `.
685
689
686
690
key function
687
691
A key function or collation function is a callable that returns a value
@@ -875,7 +879,8 @@ Glossary
875
879
Old name for the flavor of classes now used for all class objects. In
876
880
earlier Python versions, only new-style classes could use Python's newer,
877
881
versatile features like :attr: `~object.__slots__ `, descriptors,
878
- properties, :meth: `__getattribute__ `, class methods, and static methods.
882
+ properties, :meth: `~object.__getattribute__ `, class methods, and static
883
+ methods.
879
884
880
885
object
881
886
Any data with state (attributes or value) and defined behavior
@@ -955,7 +960,7 @@ Glossary
955
960
finders implement.
956
961
957
962
path entry hook
958
- A callable on the :data: `sys.path_hook ` list which returns a :term: `path
963
+ A callable on the :data: `sys.path_hooks ` list which returns a :term: `path
959
964
entry finder ` if it knows how to find modules on a specific :term: `path
960
965
entry `.
961
966
@@ -1089,18 +1094,18 @@ Glossary
1089
1094
sequence
1090
1095
An :term: `iterable ` which supports efficient element access using integer
1091
1096
indices via the :meth: `~object.__getitem__ ` special method and defines a
1092
- :meth: `__len__ ` method that returns the length of the sequence.
1097
+ :meth: `~object. __len__ ` method that returns the length of the sequence.
1093
1098
Some built-in sequence types are :class: `list `, :class: `str `,
1094
1099
:class: `tuple `, and :class: `bytes `. Note that :class: `dict ` also
1095
- supports :meth: `~object.__getitem__ ` and :meth: `__len__ `, but is considered a
1100
+ supports :meth: `~object.__getitem__ ` and :meth: `! __len__ `, but is considered a
1096
1101
mapping rather than a sequence because the lookups use arbitrary
1097
1102
:term: `immutable ` keys rather than integers.
1098
1103
1099
1104
The :class: `collections.abc.Sequence ` abstract base class
1100
1105
defines a much richer interface that goes beyond just
1101
- :meth: `~object.__getitem__ ` and :meth: `__len__ `, adding :meth: ` count `,
1102
- :meth: `index `, :meth: `__contains__ `, and
1103
- :meth: `__reversed__ `. Types that implement this expanded
1106
+ :meth: `~object.__getitem__ ` and :meth: `~object. __len__ `, adding
1107
+ :meth: `count `, :meth: ` index `, :meth: `~object. __contains__ `, and
1108
+ :meth: `~object. __reversed__ `. Types that implement this expanded
1104
1109
interface can be registered explicitly using
1105
1110
:func: `~abc.ABCMeta.register `.
1106
1111
0 commit comments