General question about Python design goals

Steve Holden steve at holdenweb.com
Thu Dec 1 07:52:41 EST 2005


Mike Meyer wrote:
> Paul Rubin <http://phr.cx@NOSPAM.invalid> writes:
[...]
> Did somebody actually use "Practicality beats purity" as an excuse for
> not making list.count and string.count have the same arguments? If so,
> I missed it. I certainly don't agree with that - count ought to work
> right in this case.
> 
I agree that the two methods are oddly inconsonant. But then since the 
introduction of the "has substring" meaning for the "in" operator, 
strings and lists are also inconsistent over that operation.

> 
>>A suitably factored implementation might handle lists and strings
>>with the exact same code and not incur any extra cost at all.  That
>>type of thing happens all the time here.
>
I don't think this would make much sense in present-day Python, mostly 
because there's no such thing as a character, only a string of length 
one. So a string is actually a sequence of sequences of length one. I 
guess this is one of those cases where practicality beat purity. It's as 
though an indexing operation on a list got you a list of length one 
rather than the element at that index. Strings have always been 
anomalous in this respect.

> 
> If it happens all the time, you shouldn't have any trouble nameing a
> number of things that a majority of users think are misfeatures that
> aren't being fixed. Could you do that?
> 
Doubtless he could. Paul's a smart guy. The missing element will be 
unanimity on the rationale.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list