fakeaddress at nowhere.org
Sun Sep 5 22:17:39 CEST 2004
Donn Cave wrote:
> Maybe the problem is that tuples have too many features already.
> It's sort of silly that they're indexed by number, and if that
> weren't allowed, we would find fewer people trying to make lists
> of them.
Plus lists have the mis-feature that we can mix types.
The talk of how lists and tuples are supposed to be used
suggests that we want lists of any type, but only on type in
each list. Tuples should be indexed by statically know values.
We should treat each kind of tuple as a distinct type, that we
should not mix in a list, so should not be able to justify
[(5, 4.23), ("Hi", )]
as a list of one type, simply because the type is 'tuple'. Since
the structure of tuples would be statically known, we can dump
the (item,) notation and just make any item the same thing as
the one-tuple holding that item.
Alas, that's ML, not Python. Were that Python's designers'
intent, why isn't it part of Python's design? Why would we want
to live within the confines of static typing, but without the
safety and efficiency advantages of a type-checking compiler?
In Python, tuples are immutable, hashable lists. Deal with it.
More information about the Python-list