summaryrefslogtreecommitdiffstats
path: root/Doc/lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-01-15 15:46:05 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-01-15 15:46:05 (GMT)
commit3801ec7ff32744e63c631e15a8305c2d5915ac34 (patch)
tree01db5864f6fc3e9cb8b989f26045eb6ad109530c /Doc/lib
parentb32c886d7104a5c6bf43391aa955c80ef858945e (diff)
downloadcpython-3801ec7ff32744e63c631e15a8305c2d5915ac34.zip
cpython-3801ec7ff32744e63c631e15a8305c2d5915ac34.tar.gz
cpython-3801ec7ff32744e63c631e15a8305c2d5915ac34.tar.bz2
Document that __cmp__() is not defined for sets.
Note, that list.sort() is undefined for lists of sets. Add the ... prompt to the example so it runs in doctest.
Diffstat (limited to 'Doc/lib')
-rw-r--r--Doc/lib/libsets.tex15
1 files changed, 12 insertions, 3 deletions
diff --git a/Doc/lib/libsets.tex b/Doc/lib/libsets.tex
index 046463e..646e205 100644
--- a/Doc/lib/libsets.tex
+++ b/Doc/lib/libsets.tex
@@ -110,6 +110,15 @@ subset of the second set (is a subset, but is not equal).
A set is greater than another set if and only if the first set is a proper
superset of the second set (is a superset, but is not equal).
+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 of each other, so \emph{none} of the following are true:
+\code{\var{a}<\var{b}}, \code{\var{a}==\var{b}}, or \code{\var{a}>\var{b}}.
+Accordingly, sets do not implement the \method{__cmp__} method.
+
+Since sets only define partial ordering (subset relationships), the output
+of the \method{list.sort()} method is undefined for lists of sets.
+
The following table lists operations available in \class{ImmutableSet}
but not found in \class{Set}:
@@ -175,9 +184,9 @@ False
>>> employees.issuperset(engineers)
True
>>> for group in [engineers, programmers, management, employees]:
- group.discard('Susan') # unconditionally remove element
- print group
-
+... group.discard('Susan') # unconditionally remove element
+... print group
+...
Set(['Jane', 'Marvin', 'Janice', 'John', 'Jack'])
Set(['Janice', 'Jack', 'Sam'])
Set(['Jane', 'Zack', 'Jack'])