diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 4e7729c83f49a41..6f2774895200ad4 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -4106,8 +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'}``, in addition to the -:class:`set` constructor. +of elements within braces, for example: ``{'jack', 'sjoerd'}``. Sets can +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. The constructors for both classes work the same: @@ -4303,7 +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'}``, or by the :class:`dict` constructor. +'jack', 4127: 'sjoerd'}``, by a dict comprehension, for example: ``{x: x**2 for +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)