diff options
author | Guido van Rossum <guido@python.org> | 2002-08-20 20:05:23 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-08-20 20:05:23 (GMT) |
commit | 290f1870f121a60d267f52fa420d10a1187b8a4d (patch) | |
tree | a66ce269d424539bad4fea34a65346863660b632 /Lib/sets.py | |
parent | 0bd783228538b761e9b75cea3f42931c2d4ba6c6 (diff) | |
download | cpython-290f1870f121a60d267f52fa420d10a1187b8a4d.zip cpython-290f1870f121a60d267f52fa420d10a1187b8a4d.tar.gz cpython-290f1870f121a60d267f52fa420d10a1187b8a4d.tar.bz2 |
Add a note reminding the reader that sets are not sequences. I
received feedback that was based in the misunderstanding that sets
were sequences.
Diffstat (limited to 'Lib/sets.py')
-rw-r--r-- | Lib/sets.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/sets.py b/Lib/sets.py index 2d44c28..4df30f8 100644 --- a/Lib/sets.py +++ b/Lib/sets.py @@ -4,6 +4,16 @@ This module implements sets using dictionaries whose values are ignored. The usual operations (union, intersection, deletion, etc.) are provided as both methods and operators. +Important: sets are not sequences! While they support 'x in s', +'len(s)', and 'for x in s', none of those operations are unique for +sequences; for example, mappings support all three as well. The +characteristic operation for sequences is subscripting with small +integers: s[i], for i in range(len(s)). Sets don't support +subscripting at all. Also, sequences allow multiple occurrences and +their elements have a definite order; sets on the other hand don't +record multiple occurrences and don't remember the order of element +insertion (which is why they don't support s[i]). + The following classes are provided: BaseSet -- All the operations common to both mutable and immutable |