-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
bpo-23677: Mention dict and set comprehension in stdtypes #20027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
60b4c94
bpo-23677: Mention dict and set comprehension
furkanonder 03d76e9
fix typo
furkanonder 5a3dd75
Update stdtypes.rst
furkanonder 8a116b5
Update stdtypes.rst
furkanonder ae7bdab
Merge branch 'bpo-23677' of github.com:furkanonder/cpython into bpo-2…
furkanonder 2071830
Update set description
furkanonder e8a83fa
Update Doc/library/stdtypes.rst
rhettinger e144987
Update the description of the creation of dict
furkanonder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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. | ||||||||||||||||
|
Comment on lines
+4109
to
+4112
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
| 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)``. | ||||||||||||||||
|
Comment on lines
+4308
to
+4310
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Link the glossary term |
||||||||||||||||
|
|
||||||||||||||||
| .. class:: dict(**kwarg) | ||||||||||||||||
| dict(mapping, **kwarg) | ||||||||||||||||
|
|
||||||||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.