[Python-Dev] casefolding in pathlib (PEP 428)

Paul Moore p.f.moore at gmail.com
Fri Apr 12 12:06:30 CEST 2013

On 12 April 2013 09:39, Antoine Pitrou <solipsis at pitrou.net> wrote:

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

If glob("*.py") failed to find SETUP.PY on Windows, that would be a
usability disaster. Too many tools still exist that mangle filename case
for anything else to be acceptable. For an easy example, the standard
Windows ssh client, putty, is distributed as PUTTY.EXE.
shutil.which('putty') needs to find that file if it's to be of any
practical use.

For comparisons, I think naive Windows users would expect __eq__
comparisons to work case insensitively, but Windows users with any level of
understanding of cross-platform portability issues would be comfortable
with the idea that this is risky. Having said that, currently there aren't
any "pathname comparisons" as such, just string comparisons which "clearly"
need application handling.

In all honesty, I don't think that equality comparison for path *objects*
(as opposed to "pathnames" as strings) is necessarily even well defined. If
someone has two path objects and tries to compare them for equality, my
first question would be whether that's really what they want to do... (But
case-sensitive comparison, with copious warnings, is probably a reasonable
practical compromise).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130412/dff868a5/attachment.html>

More information about the Python-Dev mailing list