Case-insensitive string equality

Steve D'Aprano steve+python at pearwood.info
Thu Aug 31 08:49:26 EDT 2017


On Thu, 31 Aug 2017 05:51 pm, Serhiy Storchaka wrote:

> 31.08.17 10:10, Steven D'Aprano пише:
>> (iii) Not every two line function needs to be in the standard library.
>> Just add this to the top of every module:
>> 
>> def equal(s, t):
>>      return s.casefold() == t.casefold()
> 
> This is my answer.
> 
>> Unsolved problems:
>> 
>> This proposal doesn't help with sets and dicts, list.index and the `in`
>> operator either.
> 
> This is the end of the discussion.

Your answer of an equal() function doesn't help with sets and dicts either.

So I guess we're stuck with no good standard answer:

- the easy two-line function doesn't even come close to solving the problem
  of case-insensitive string operations;

- but we can't have case-insensitive string operations because too many 
  people say "just use this two-line function".




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list