preferring [] or () in list of error codes?

Gunter Henriksen gunterhenriksen at gmail.com
Thu Jun 11 12:47:42 EDT 2009


> [In this tuple]
>    dodge_city = (1781, 1870, 1823)
>    (population, feet_above_sea_level, establishment_year) = dodge_city
> each index in the sequence implies something very
> different about each value. The semantic meaning
> of each index is *more* than just the position in
> the sequence; it matters *for interpreting that
> component*, and that component would not mean the
> same thing in a different index position. A tuple
> is the right choice, for that reason.

I think I would have difficulty holding a position
that this should not be a class (or equivalent via
namedtuple()) or a dict.  It seems to me like a case
could be made that there are far more situations where
it makes sense to use tuples as immutable sequences than
as objects whose attributes are named implicitly by an
index.  This dodge_city definitely does not seem to me
like a good candidate for a plain tuple.



More information about the Python-list mailing list