[Python-Dev] casefolding in pathlib (PEP 428)
solipsis at pitrou.net
Fri Apr 12 14:17:43 CEST 2013
Le Fri, 12 Apr 2013 08:06:37 -0400,
Devin Jeanpierre <jeanpierreda at gmail.com> a écrit :
> On Fri, Apr 12, 2013 at 4:39 AM, Antoine Pitrou <solipsis at pitrou.net>
> > Ok, I've taken a look at the code. Right now lower() is used for two
> > purposes:
> > 1. comparisons (__eq__ and __ne__)
> > 2. globbing and matching
> > While (1) could be dropped, for (2) I think we want glob("*.py") to
> > find "SETUP.PY" under Windows. Anything else will probably be
> > surprising to users of that platform.
> OT, but, why is .lower() used for case folding in these use-cases
> instead of .casefold()?
Because the code was written before str.casefold() was introduced.
But, actually, if we want to approximate Windows' casefolding behaviour,
str.lower() may be better.
More information about the Python-Dev