tuples, index method, Python's design

Antoon Pardon apardon at forel.vub.ac.be
Tue Apr 10 03:42:19 EDT 2007


On 2007-04-09, Georg Brandl <g.brandl at gmx.net> wrote:
> Paul Rubin schrieb:
>> Carsten Haese <carsten at uniqsys.com> writes:
>>> Will tuples also get a sort method? What about append and extend? pop?
>>> __iadd__? __delslice__?
>> 
>> They are immutable so they won't get .sort() etc.  sorted(...) already
>> works on them.
>> 
>>> How many brain cells are actually freed up by not having to remember
>>> that *one* method that you'd never use doesn't exist?
>> 
>> I dunno but I do know that Ruby is attracting a lot of potential Python
>> users because it apparently has fewer of these inconsistencies.
>
> It remains to be proven that it is an inconsistency, rather than a design
> decision.

The two don't contradict. A design decision can introduce an
inconsistency. AFAICS having an index method on tuples seems
rather natural. Looking for the index of a particular item in
your sequence seems just as usefull independant of the nature
of your sequence. So unless there is some rather forcefull
argument it seems inconsistent to have some sequences lacking
this method.

-- 
Antoon Pardon



More information about the Python-list mailing list