tuples, index method, Python's design

Steve Holden steve at holdenweb.com
Tue Apr 10 17:29:43 CEST 2007


Paul Boddie wrote:
> On 10 Apr, 15:57, Steve Holden <s... at holdenweb.com> wrote:
>> The point I am trying to make is that circumstances alter cases, and that we
>> can't always rely on our intuition to determine how specific methods
>> work, let alone whether they are available.
> 
> But it's telling that by adopting precisely the implementation that we
> currently have for lists, we can have a tuple method which does what
> most people would reasonably expect. "Why are we suddenly getting
> single characters instead of whole strings?" people have presumably
> exclaimed often enough, illustrating that the sequence nature of
> strings is a controversial topic. Lists and tuples, however, don't
> have such controversial baggage.
> 
You can call something non-controversial when it generates a thread like 
this? :-) It's really a storm in a teacup. The acid test would be to 
generate a patch that added the method and then see if you could get a 
committer to commit it. All else (including my own contributions) is 
mere hot air.

>> I hear the screams of "just add the index() method to tuples and have
>> done with it" and, to an extent, can sympathize with them. But that way
>> lies creeping featurism and the next thing you know we'll have a ternary
>> operator in the language - oh wait, we do now!
> 
> Yes, but the cost of adding index to tuples is minimal, and the mental
> cost to programmers is arguably negative. Meanwhile, we now have to
> put up with the syntactic bodge that is the ternary operator until the
> time comes when it gets deprecated as something that didn't work out
> or wasn't really necessary (in Python 4000, perhaps), meaning that we
> now have to read third-party code more carefully, the people writing
> editors and tools have to change their lexers/parsers again, and so
> on.
> 
What can I say? Every language has warts. Some people were as anxious to 
see if ... else (which I regard as a wart) put in as others are to see 
tuple.index().

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb     http://del.icio.us/steve.holden
Recent Ramblings       http://holdenweb.blogspot.com




More information about the Python-list mailing list