[Patches] [ python-Patches-1696444 ] Adding an index method to tuples

SourceForge.net noreply at sourceforge.net
Mon Apr 9 19:08:07 CEST 2007

Patches item #1696444, was opened at 2007-04-08 09:35
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Paul Boddie (pboddie)
Assigned to: Nobody/Anonymous (nobody)
Summary: Adding an index method to tuples

Initial Comment:
This is just a simple copy and paste from the list implementation - not exactly the most elegant solution, but perhaps a demonstration that technical limitations aren't the reason why the tuple doesn't have an index method. I suppose a common sequence function library would be best if such a feature were eventually deemed compelling.


>Comment By: Raymond Hettinger (rhettinger)
Date: 2007-04-09 12:08

Logged In: YES 
Originator: NO

FWIW, I am no longer satisfied with the pat answer that "tuples are not
immutable lists" or the "lists for for homogenous data, tuples are for
hetrogenous data".

Whether tuples should grow index() and count() methods should depend
solely on whether real use cases arise often enough to warrant the new
methods being added.

Another consideration is that this feature request and discussion comes up
so often that it may be worthwhile just to give-in to conserve our limited
resources of time and brain-power.


Comment By: Josiah Carlson (josiahcarlson)
Date: 2007-04-09 11:24

Logged In: YES 
Originator: NO

Adding an .index method to tuples suggests that a tuple is more or less an
immutable list.  This is not the case.  Typically tuples are used to hold
disparate pieces of information of different semantics and types, where as
a list typically contains a list of a single type with identical meaning. 
For examples we merely need to look at the outputs of str.partition and
str.split .

Suggested close.


You can respond by visiting: 

More information about the Patches mailing list