Range Operation pre-PEP
Ben Hutchings
ben.hutchings at roundpoint.com
Wed May 9 20:27:22 EDT 2001
Douglas Alan <nessus at mit.edu> writes:
> Speaking of creeping-featurism, how come we have list comprehension,
> but not tuple comprehension? Seems inconsistent to me.
A list contains a variable number of homogeneous values, e.g. the
lines of a file. Lists are like arrays in other languages. A tuple
contains a fixed number of heterogeneous values where each element has
a distinct meaning e.g. (year, month, day) for a date. Tuples are
like data structures or product types in other languages, except that
their types and fields are nameless. Comprehensions work with a
variable number of homogeneous values, so they produce lists.
--
Any opinions expressed are my own and not necessarily those of Roundpoint.
More information about the Python-list
mailing list