From 3801ec7ff32744e63c631e15a8305c2d5915ac34 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 15 Jan 2003 15:46:05 +0000 Subject: [PATCH] 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. --- Doc/lib/libsets.tex | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Doc/lib/libsets.tex b/Doc/lib/libsets.tex index 046463efbe6..646e2054608 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'])