Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f8105cee
Commit
f8105cee
authored
May 08, 2008
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 2778. Document the temporary frozenset swap in __contains__(), remove(), and discard().
parent
bf5bd9f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
Doc/library/stdtypes.rst
Doc/library/stdtypes.rst
+12
-9
No files found.
Doc/library/stdtypes.rst
View file @
f8105cee
...
...
@@ -1585,7 +1585,7 @@ proper superset of the second set (is a superset, but is not equal).
Instances of :class:`set` are compared to instances of :class:`frozenset` based
on their members. For example, ``set('abc') == frozenset('abc')`` returns
``True``.
``True``
and so does ``set('abc') in set([frozenset('abc')])``
.
The subset and equality comparisons do not generalize to a complete ordering
function. For example, any two disjoint sets are not equal and are not subsets
...
...
@@ -1624,18 +1624,18 @@ apply to immutable instances of :class:`frozenset`:
Update the set, keeping only elements found in either set, but not in both.
.. method:: set.add(el)
.. method:: set.add(el
em
)
Add element *el* to the set.
Add element *el
em
* to the set.
.. method:: set.remove(el)
.. method:: set.remove(el
em
)
Remove element *el
* from the set. Raises :exc:`KeyError` if *el
* is not
Remove element *el
em* from the set. Raises :exc:`KeyError` if *elem
* is not
contained in the set.
.. method:: set.discard(el)
.. method:: set.discard(el
em
)
Remove element *el* from the set if it is present.
Remove element *el
em
* from the set if it is present.
.. method:: set.pop()
...
...
@@ -1652,8 +1652,11 @@ Note, the non-operator versions of the :meth:`update`,
:meth:`symmetric_difference_update` methods will accept any iterable as an
argument.
The design of the set types was based on lessons learned from the Python
implementation found in the :mod:`sets` module.
Note, the *elem* argument to the :meth:`__contains__`, :meth:`remove`, and
:meth:`discard` methods may be a set. To support searching for an equivalent
frozenset, the *elem* set is temporarily mutated during the search and then
restored. During the search, the *elem* set should not be read or mutated
since it does not have a meaningful value.
.. seealso::
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment