tuples, index method, Python's design
Duncan Booth
duncan.booth at invalid.invalid
Tue Apr 10 08:40:30 EDT 2007
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.
> 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.
Fair enough though. I'll assume you cannot think of a suitable use case
either.
More information about the Python-list
mailing list