[Python-checkins] python/dist/src/Lib sets.py,1.2,1.3
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Tue, 20 Aug 2002 13:05:27 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv3542
Modified Files:
sets.py
Log Message:
Add a note reminding the reader that sets are not sequences. I
received feedback that was based in the misunderstanding that sets
were sequences.
Index: sets.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sets.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** sets.py 19 Aug 2002 16:29:58 -0000 1.2
--- sets.py 20 Aug 2002 20:05:23 -0000 1.3
***************
*** 5,8 ****
--- 5,18 ----
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: