tuples, index method, Python's design

Paul Boddie paul at boddie.org.uk
Fri Apr 6 15:56:11 CEST 2007

C.L. wrote:
> That doesn't change the fact that this is unfriendly design. It's an ugly
> inconsistent chunk of a Python's past in which built-in types didn't behave like
> objects. It sticks out like a sore thumb, maybe just not very often.

When this topic last appeared on my radar, I ended up writing a long
message about it:



> *sighs* just what I expected: another idle troll defending something just for
> the sake of defending it. On the other hand, thanks 7stud, for the truly helpful
> response.

The problem with 7stud's quote from GvR is that it's out of date:
tuples do have methods now, as you've noticed, but just not the index
method. Previously, I've missed that method, and it wouldn't be hard
to add it to the tuple class (in CPython's own source code), but one
has to wonder whether it's really necessary, or at least as necessary
as for other classes. Certainly, there's a trade-off between essential
functionality and having, say, 100 methods which are all useful to
someone but which make interactive introspection a rather tedious and
confusing business.


More information about the Python-list mailing list