python 2.7.12 on Linux behaving differently than on Windows

Chris Angelico rosuav at
Thu Dec 8 21:52:19 EST 2016

On Fri, Dec 9, 2016 at 12:34 PM, BartC <bc at> wrote:
> With a case-sensitive file system, how do you search only for 'harry', not
> knowing what combinations of upper and lower case have been used? (It's a
> good thing Google search isn't case sensitive!)

This is handled by "case correlations", which aren't quite the same as
case conversions. In Python, that's the .casefold() method. You
casefold the string "harry", and then casefold every file name that
might potentially match, and see if they become the same. Taking my
original example string:

>>> "ßẞıİÅσςσ".casefold()

Any string that casefolds to that same string should be considered a
match. This does NOT stop you from having multiple such files in the

>>  much less other European languages (Russian, Greek), and
>> certainly I had no way of working with non-alphabetic languages
>> (Chinese, Japanese). Nor right-to-left languages (Hebrew, Arabic).
> Did you really need to work with all those languages, or is this a generic
> 'I'.

In the 90s? No, I didn't, otherwise I'd have had a lot of trouble.
Today? Yep. I can, and I do. Not as much as I work with English, but I
definitely do support them. Took a good bit of work to make some of
the RTL text behaviours the way I wanted them, but everything else was
pretty smooth.


More information about the Python-list mailing list