Archives for the Date February 13th, 2008

Learning Python: Chapter 9

Tuples are immutable sequences.
Tuples with just one element require a comma after the element the be distinguishable from an expression.
No methods can be called on tuples.
Comparisons and truth tests traverse data structures.

>>> items = [ [random.randint(0, 2) for m in range(3)] for n in range(10) ]
>>> items
[[1, 2, 0], [1, 0, 1], [2, 0, 2], [...]