diff options
author | Miss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-10-25 02:53:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-25 02:53:18 (GMT) |
commit | 60bef61f717dde915058b03159b2c2e97d765858 (patch) | |
tree | 2b4b5c3811eef8e3e48305c387a14f5f95136423 /Doc/glossary.rst | |
parent | eac21a048bb6f33b20224a5d6896c34d1d6abc8e (diff) | |
download | cpython-60bef61f717dde915058b03159b2c2e97d765858.zip cpython-60bef61f717dde915058b03159b2c2e97d765858.tar.gz cpython-60bef61f717dde915058b03159b2c2e97d765858.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>
(cherry picked from commit 2d55aa9e37c9c84f4f6a8135d0326da0bcd8f38b)
Co-authored-by: Florian Dahlitz <f2dahlitz@freenet.de>
Diffstat (limited to 'Doc/glossary.rst')
-rw-r--r-- | Doc/glossary.rst | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Doc/glossary.rst b/Doc/glossary.rst index 632ed3f..d94fc44 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.ABCMeta.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. |