tuples, index method, Python's design

Antoon Pardon apardon at forel.vub.ac.be
Tue Apr 10 15:25:21 CEST 2007


On 2007-04-10, Duncan Booth <duncan.booth at invalid.invalid> wrote:
> Antoon Pardon <apardon at forel.vub.ac.be> wrote:
>
>> On 2007-04-10, Duncan Booth <duncan.booth at invalid.invalid> wrote:
>>> There is a cost to every new language feature: it has to be
>>> implemented, documented, maintained, and above all learned by the
>>> users. Good design involves, in part, not adding to these burdens
>>> except where there is a benefit at least equal to the cost.
>> 
>> So what is the easiest to learn: "All sequences have an index method"
>> or "Such and so sequences have an index method and others don't"
>> 
>> Which of the above is the easiest to document?
>
> The second would be if it were true. However it would mean you would have 
> to add an index method to *all* sequences.
>
> FWIW, The current documentation says that 's.index' is a method defined on 
> all *mutable* sequence types: almost as simple as your second wording but 
> unfortunately misleading since strings also have index.

Which illustrate that the mutable unmutable distinction is not very
usefull to decide whether a sequence could use "index" or not.

>> If someone states: "Show me your use case for using tuple.index and I
>> will show you how to avoid it." or words to that effect I think there
>> is little use trying.
>
> I genuinely cannot think of a use case. I didn't ask you to suggest one so 
> I could show you how to avoid it, I asked you to suggest one so that we 
> could take the discussion from the purely hypothetical to a more concrete 
> discussion of whether it would be a worthwhile enhancement.

I have given a use case in an other article in this thread. Feel free to
comment.

-- 
Antoon Pardon



More information about the Python-list mailing list