<br>
I think because strings are considered *sequences* that they're also
legitimately *collections*.
<a href="http://docs.python.org/lib/typesseq.html">http://docs.python.org/lib/typesseq.html</a> <br>
<br>
i.e. it's hard for me to think an object called a "sequence" wouldn't
also be a "collection" (though not all collections are sequences). <br>
<br>
's' is a sequence with one element.<br>
<br>
iter is supposed to take a "collection" as its argument, and strings may be fed to iter.<br>
<br>
>>> s = iter('a')<br>
>>> s.next()<br>
'a'<br>
<br>
Another author who lumps strings with lists as collections is Dave
Kuhlman in Python 101: "Collections are things like strings (arrays of
characters), lists, tuples, and dictionaries."
<a href="http://www.rexx.com/~dkuhlman/python_101/python_101.html">http://www.rexx.com/~dkuhlman/python_101/python_101.html</a><br>
<br>
Given there's no formal "collection interface" like in Java (a list of
methods any collection must support), I suppose the concept is a little
hazy around the edges in Python world. "Iterable" is perhaps
better defined?<br>
<br>
SmallTalk definitely considers strings under the umbrella of collections.<br>
<br>
Currently the page reads:<br>
<br>
"""<br>
Our first practice sessions involved using Python's primitive objects,
such as different types of number, plus characters. Then we started looking
at collection types, which are designed to organize information in easy-to-use
<strong>data structures</strong>.
<p>Examples of data structures are: </p>
<blockquote>
<p><strong><font color="#3333ff">[a, b, c]</font> <font color="#ff3333">#
list</font><br>
<font color="#3333ff">{a :1, b :2, c :3}</font> <font color="#ff3333">#
dictionary</font><br>
<font color="#3333ff">"abc"</font> <font color="#ff3333">#
string</font><br>
<font color="#3333ff">(a, b, c)</font> <font color="#ff3300"># tuple</font></strong></p>
</blockquote>
Using data structures, we're able to save a lot of information in a ready-to-use
form.<br>
"""<br>
<br>
It's a little ambiguous, in that I use the word 'character' but as you
point out, there's no 'character' type as distinct from 'string' in
Python. <br>
<br>
However, given the 8th grade audience, I think the important thing is
just to get letters mixed in with numbers when we speak of 'types of
object' (they're used to the idea of integers versus floats, plus one
kid brought up complex -- so then we have letters too, and all the
stuff you might do with 'em).<br>
<br>
...I may reword. Keep those suggestions coming -- useful thinking on my end.<br>
<br>
Kirby<br><br><div><span class="gmail_quote">On 1/1/06, <b class="gmail_sendername">Scott David Daniels</b> <<a href="mailto:Scott.Daniels@acm.org">Scott.Daniels@acm.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
kirby urner wrote:<br>> ...<br>> Python:<br>> shell mode<br>> primitive objects vs. collections<br>> Collections:<br>> list<br>> dictionary<br>> string<br>> tuple<br><br>'d move string out of Collections. It cannot have elements of a
<br>different type (there is no character type), nor is it mutable.<br>Better to be more standard and not call it a collection. Later<br>you can say it behaves in some ways like an ordered list of the<br>individual characters in the string.
<br><br>--Scott David Daniels<br><a href="mailto:Scott.Daniels@Acm.Org">Scott.Daniels@Acm.Org</a><br><br>_______________________________________________<br>Edu-sig mailing list<br><a href="mailto:Edu-sig@python.org">Edu-sig@python.org
</a><br><a href="http://mail.python.org/mailman/listinfo/edu-sig">http://mail.python.org/mailman/listinfo/edu-sig</a><br></blockquote></div><br>