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

Terry Reedy tjreedy at
Tue Jun 9 14:29:47 EDT 2009

Steven D'Aprano wrote:

>> James Tauber explains this at
>> <URL:
>> 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
).  Operationally, they are now general immutable sequences.  Period.

Terry Jan Reedy

More information about the Python-list mailing list