Share Code Tips

Dave Angel davea at davea.name
Fri Jul 19 21:51:32 EDT 2013


On 07/19/2013 09:04 PM, Devyn Collier Johnson wrote:
>

      <snip>
>>
> Chris Angelico said that casefold is not perfect. In the future, I want
> to make the perfect international-case-insensitive if-statement. For
> now, my code only supports a limited range of characters. Even with
> casefold, I will have some issues as Chris Angelico mentioned. Also, "ß"
> is not really the same as "ss".
>

Sure, the casefold() method has its problems.  But you're going to avoid 
using it till you can do a "perfect" one?

Perfect in what context?  For "case sensitively" comparing people's 
names in a single language in a single country?  Perhaps that can be 
made perfect.  For certain combinations of language and country.

But if you want to compare words in an unspecified language with an 
unspecified country, it cannot be done.

If you've got a particular goal in mind, great.  But as a library 
function, you're better off using the best standard method available, 
and document what its limitations are.  One way of documenting such is 
to quote the appropriate standards, with their caveats.


By the way, you mentioned earlier that you're restricting yourself to 
Latin characters.  The lower() method is inadequate for many of those as 
well.  Perhaps you meant ASCII instead.

-- 
DaveA




More information about the Python-list mailing list