summaryrefslogtreecommitdiffstats
path: root/Doc/glossary.rst
diff options
context:
space:
mode:
authorFlorian Dahlitz <f2dahlitz@freenet.de>2020-10-20 21:27:07 (GMT)
committerGitHub <noreply@github.com>2020-10-20 21:27:07 (GMT)
commit2d55aa9e37c9c84f4f6a8135d0326da0bcd8f38b (patch)
tree32b2fdc5e25397a54d3648fea8928e16cb9edf6b /Doc/glossary.rst
parent5ab27cc518f614a0b954ff3eb125290f264242d5 (diff)
downloadcpython-2d55aa9e37c9c84f4f6a8135d0326da0bcd8f38b.zip
cpython-2d55aa9e37c9c84f4f6a8135d0326da0bcd8f38b.tar.gz
cpython-2d55aa9e37c9c84f4f6a8135d0326da0bcd8f38b.tar.bz2
bpo-29981: Add examples and update index for set, dict, and generator comprehensions'(GH-20272)
Co-authored-by: RĂ©mi Lapeyre <remi.lapeyre@henki.fr>
Diffstat (limited to 'Doc/glossary.rst')
-rw-r--r--Doc/glossary.rst12
1 files changed, 12 insertions, 0 deletions
diff --git a/Doc/glossary.rst b/Doc/glossary.rst
index 9fdbdb1..4f0654b 100644
--- a/Doc/glossary.rst
+++ b/Doc/glossary.rst
@@ -308,6 +308,12 @@ Glossary
keys can be any object with :meth:`__hash__` and :meth:`__eq__` methods.
Called a hash in Perl.
+ dictionary comprehension
+ A compact way to process all or part of the elements in an iterable and
+ return a dictionary with the results. ``results = {n: n ** 2 for n in
+ range(10)}`` generates a dictionary containing key ``n`` mapped to
+ value ``n ** 2``. See :ref:`comprehensions`.
+
dictionary view
The objects returned from :meth:`dict.keys`, :meth:`dict.values`, and
:meth:`dict.items` are called dictionary views. They provide a dynamic
@@ -1026,6 +1032,12 @@ Glossary
interface can be registered explicitly using
:func:`~abc.register`.
+ set comprehension
+ A compact way to process all or part of the elements in an iterable and
+ return a set with the results. ``results = {c for c in 'abracadabra' if
+ c not in 'abc'}`` generates the set of strings ``{'r', 'd'}``. See
+ :ref:`comprehensions`.
+
single dispatch
A form of :term:`generic function` dispatch where the implementation is
chosen based on the type of a single argument.