Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3801ec7

Browse files
committed
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.
1 parent b32c886 commit 3801ec7

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

Doc/lib/libsets.tex

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ \subsection{Set Objects \label{set-objects}}
110110
A set is greater than another set if and only if the first set is a proper
111111
superset of the second set (is a superset, but is not equal).
112112

113+
The subset and equality comparisons do not generalize to a complete
114+
ordering function. For example, any two disjoint sets are not equal and
115+
are not subsets of each other, so \emph{none} of the following are true:
116+
\code{\var{a}<\var{b}}, \code{\var{a}==\var{b}}, or \code{\var{a}>\var{b}}.
117+
Accordingly, sets do not implement the \method{__cmp__} method.
118+
119+
Since sets only define partial ordering (subset relationships), the output
120+
of the \method{list.sort()} method is undefined for lists of sets.
121+
113122
The following table lists operations available in \class{ImmutableSet}
114123
but not found in \class{Set}:
115124

@@ -175,9 +184,9 @@ \subsection{Example \label{set-example}}
175184
>>> employees.issuperset(engineers)
176185
True
177186
>>> for group in [engineers, programmers, management, employees]:
178-
group.discard('Susan') # unconditionally remove element
179-
print group
180-
187+
... group.discard('Susan') # unconditionally remove element
188+
... print group
189+
...
181190
Set(['Jane', 'Marvin', 'Janice', 'John', 'Jack'])
182191
Set(['Janice', 'Jack', 'Sam'])
183192
Set(['Jane', 'Zack', 'Jack'])

0 commit comments

Comments
 (0)