Steven D'Aprano wrote:
James Tauber explains this at
<URL:http://jtauber.com/blog/2006/04/15/
python_tuples_are_not_just_constant_lists/>.
He doesn't really explain anything though, he merely states it as
revealed wisdom. The closest he comes to an explanation is to declare
that in tuples "the index in a tuple has an implied semantic. The point
of a tuple is that the i-th slot means something specific. In other
words, it's a index-based (rather than name based) datastructure." But he
gives no reason for why we should accept that as true for tuples but not
lists.
It may be that that's precisely the motivation Guido had when he
introduced tuples into Python, but why should we not overload tuples with
more meanings than Guido (hypothetically) imagined? In other words, why
*shouldn't* we treat tuples as immutable lists, if that helps us solve a
problem effectively?
I believe that we should overload tuples with *less* specific meaning
than originally. In 3.0, tuples have *all* the general sequence
operations and methods, including .index() and .count(). This was not
true in 2.5 (don't know about 2.6), which is why tuples are yet not
documented as having those two methods (reported in
http://bugs.python.org/issue4966
). Operationally, they are now general immutable sequences. Period.
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list