From 60b4c94cf4497351752033066af1f9ecb943d346 Mon Sep 17 00:00:00 2001 From: furkanonder Date: Sun, 10 May 2020 20:43:23 +0300 Subject: [PATCH 1/7] bpo-23677: Mention dict and set comprehension --- Doc/library/stdtypes.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 4e7729c83f49a41..e549481d6857204 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -4106,8 +4106,9 @@ its contents cannot be altered after it is created; it can therefore be used as a dictionary key or as an element of another set. Non-empty sets (not frozensets) can be created by placing a comma-separated list -of elements within braces, for example: ``{'jack', 'sjoerd'}``, in addition to the -:class:`set` constructor. +of elements within braces, for example: ``{'jack', 'sjoerd'}``, by using a set +comprehension, for example ``{x for x in iterable}``, in addition to the + :class:`set` constructor. The constructors for both classes work the same: @@ -4301,9 +4302,10 @@ then they can be used interchangeably to index the same dictionary entry. (Note however, that since computers store floating-point numbers as approximations it is usually unwise to use them as dictionary keys.) -Dictionaries can be created by placing a comma-separated list of ``key: value`` -pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: -'jack', 4127: 'sjoerd'}``, or by the :class:`dict` constructor. + Dictionaries can be created by placing a comma-separated list of ``key: value`` + pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: +'jack', 4127: 'sjoerd'}``, by a dict comprehension, for example: +``{x: x**2 for x in iterable}`` or by the :class:`dict` constructor. .. class:: dict(**kwarg) dict(mapping, **kwarg) From 03d76e96fc25540b8f64333f65258390be78af32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20=C3=96nder?= Date: Sun, 10 May 2020 21:04:58 +0300 Subject: [PATCH 2/7] fix typo --- Doc/library/stdtypes.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index e549481d6857204..6276955d6da1458 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -4108,7 +4108,7 @@ a dictionary key or as an element of another set. Non-empty sets (not frozensets) can be created by placing a comma-separated list of elements within braces, for example: ``{'jack', 'sjoerd'}``, by using a set comprehension, for example ``{x for x in iterable}``, in addition to the - :class:`set` constructor. +:class:`set` constructor. The constructors for both classes work the same: @@ -4302,8 +4302,8 @@ then they can be used interchangeably to index the same dictionary entry. (Note however, that since computers store floating-point numbers as approximations it is usually unwise to use them as dictionary keys.) - Dictionaries can be created by placing a comma-separated list of ``key: value`` - pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: +Dictionaries can be created by placing a comma-separated list of ``key: value`` +pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: 'jack', 4127: 'sjoerd'}``, by a dict comprehension, for example: ``{x: x**2 for x in iterable}`` or by the :class:`dict` constructor. From 5a3dd754b60e0ca602ef21e03cd590566040d127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20=C3=96nder?= Date: Wed, 13 May 2020 02:22:27 +0300 Subject: [PATCH 3/7] Update stdtypes.rst --- Doc/library/stdtypes.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 6276955d6da1458..0dcd9d4b7a37ca2 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -4106,9 +4106,10 @@ its contents cannot be altered after it is created; it can therefore be used as a dictionary key or as an element of another set. Non-empty sets (not frozensets) can be created by placing a comma-separated list -of elements within braces, for example: ``{'jack', 'sjoerd'}``, by using a set -comprehension, for example ``{x for x in iterable}``, in addition to the -:class:`set` constructor. +of elements within braces, for example: ``{'jack', 'sjoerd'}``. Non-empty sets can +be created by using a setcomprehension, for example ``{x for x in iterable}``. +Also, set comprehensions can make both empty and non-empty sets. In addition to +the :class:`set` constructor. The constructors for both classes work the same: @@ -4304,8 +4305,9 @@ is usually unwise to use them as dictionary keys.) Dictionaries can be created by placing a comma-separated list of ``key: value`` pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: -'jack', 4127: 'sjoerd'}``, by a dict comprehension, for example: -``{x: x**2 for x in iterable}`` or by the :class:`dict` constructor. +'jack', 4127: 'sjoerd'}``, by a dict comprehension, for example: ``{x: x**2 for +x in iterable}``. Dictionaries can be created by the :class:`dict` constructor, +for example: ``dict(jack=4098, sjoerd=4127)``. .. class:: dict(**kwarg) dict(mapping, **kwarg) From 8a116b587d64a6a80eb8bf5d43f9c42bcaf5dd28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20=C3=96nder?= Date: Wed, 13 May 2020 02:22:27 +0300 Subject: [PATCH 4/7] Update stdtypes.rst --- Doc/library/stdtypes.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 6276955d6da1458..0dcd9d4b7a37ca2 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -4106,9 +4106,10 @@ its contents cannot be altered after it is created; it can therefore be used as a dictionary key or as an element of another set. Non-empty sets (not frozensets) can be created by placing a comma-separated list -of elements within braces, for example: ``{'jack', 'sjoerd'}``, by using a set -comprehension, for example ``{x for x in iterable}``, in addition to the -:class:`set` constructor. +of elements within braces, for example: ``{'jack', 'sjoerd'}``. Non-empty sets can +be created by using a setcomprehension, for example ``{x for x in iterable}``. +Also, set comprehensions can make both empty and non-empty sets. In addition to +the :class:`set` constructor. The constructors for both classes work the same: @@ -4304,8 +4305,9 @@ is usually unwise to use them as dictionary keys.) Dictionaries can be created by placing a comma-separated list of ``key: value`` pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: -'jack', 4127: 'sjoerd'}``, by a dict comprehension, for example: -``{x: x**2 for x in iterable}`` or by the :class:`dict` constructor. +'jack', 4127: 'sjoerd'}``, by a dict comprehension, for example: ``{x: x**2 for +x in iterable}``. Dictionaries can be created by the :class:`dict` constructor, +for example: ``dict(jack=4098, sjoerd=4127)``. .. class:: dict(**kwarg) dict(mapping, **kwarg) From 207183028aea158ba3b76d4b54e16b4d735c9043 Mon Sep 17 00:00:00 2001 From: Furkan Onder Date: Mon, 13 Dec 2021 20:00:18 +0300 Subject: [PATCH 5/7] Update set description --- Doc/library/stdtypes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 0dcd9d4b7a37ca2..1c949f74cfb13e9 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -4106,8 +4106,8 @@ its contents cannot be altered after it is created; it can therefore be used as a dictionary key or as an element of another set. Non-empty sets (not frozensets) can be created by placing a comma-separated list -of elements within braces, for example: ``{'jack', 'sjoerd'}``. Non-empty sets can -be created by using a setcomprehension, for example ``{x for x in iterable}``. +of elements within braces, for example: ``{'jack', 'sjoerd'}``. Sets can +be created by using a set comprehension, for example ``{x for x in iterable}``. Also, set comprehensions can make both empty and non-empty sets. In addition to the :class:`set` constructor. From e8a83fa40f1b006e98df4c65e2931cbab3a1772a Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 2 Jan 2022 13:31:41 -0800 Subject: [PATCH 6/7] Update Doc/library/stdtypes.rst Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> --- Doc/library/stdtypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 1c949f74cfb13e9..3597cf4a642f8b1 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -4107,7 +4107,7 @@ a dictionary key or as an element of another set. Non-empty sets (not frozensets) can be created by placing a comma-separated list of elements within braces, for example: ``{'jack', 'sjoerd'}``. Sets can -be created by using a set comprehension, for example ``{x for x in iterable}``. +be created by using a set comprehension, for example ``{2 * x for x in iterable}``. Also, set comprehensions can make both empty and non-empty sets. In addition to the :class:`set` constructor. From e144987d29393069312ed303260e60c7105e5717 Mon Sep 17 00:00:00 2001 From: Furkan Onder Date: Fri, 14 Jan 2022 11:42:43 +0000 Subject: [PATCH 7/7] Update the description of the creation of dict --- Doc/library/stdtypes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 3597cf4a642f8b1..6f2774895200ad4 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -4306,8 +4306,8 @@ is usually unwise to use them as dictionary keys.) Dictionaries can be created by placing a comma-separated list of ``key: value`` pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: 'jack', 4127: 'sjoerd'}``, by a dict comprehension, for example: ``{x: x**2 for -x in iterable}``. Dictionaries can be created by the :class:`dict` constructor, -for example: ``dict(jack=4098, sjoerd=4127)``. +x in iterable}``. Dictionaries can also be created by the :class:`dict` +constructor, for example: ``dict(jack=4098, sjoerd=4127)``. .. class:: dict(**kwarg) dict(mapping, **kwarg)