Case-insensitive string equality

Steve D'Aprano steve+python at pearwood.info
Fri Sep 1 22:21:51 EDT 2017


On Fri, 1 Sep 2017 01:29 am, Tim Chase wrote:

> On 2017-08-31 07:10, Steven D'Aprano wrote:
>> So I'd like to propose some additions to 3.7 or 3.8.
> 
> Adding my "yes, a case-insensitive equality-check would be useful"
> with the following concerns:
> 
> I'd want to have an optional parameter to take locale into
> consideration.  E.g.

Does regular case-sensitive equality take the locale into consideration?

How do I convince Python to return true for these?

'i'.upper() == 'İ'
'I'.lower() == 'ı'


I'm 99% sure that these are rhetorical questions where the answers are
obviously:

- No it doesn't.
- And you can't.

If regular case-sensitive string comparisons don't support the locale, why
should case-insensitive comparisons be required to?

We should not confuse "nice to have" for "must have". As far as I'm concerned,
the only "must have" is that ASCII letters do the right thing. Everything
beyond that is a "quality of implementation" issue.


In any case, thanks to everyone for their feedback. Clearly there not enough
support for this for me to even bother taking it to Python-Ideas.




-- 
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