0

In Python 3.7 or higher I want to test two pathlib.Path objects p1 and p2 for casefolded equality. Written out I want the result of

str(p1).casefold() == str(p2).casefold()

Is there a built-in function or operator for this? Or an easier/shorter way to test this?


ps: I need this on macOS, but a general solution for PosixPath and for WindowsPath is preferred.

halloleo
  • 9,216
  • 13
  • 64
  • 122

1 Answers1

-1

The only reason you could possibly want to do that is because you are working on Windows which has a case-insensitive filesystem. But pathlib knows that.

>>> from pathlib import Path
>>> uc = Path(r"C:\Program Files")
>>> lc = Path(r"c:\program files")
>>> uc==lc
True
BoarGules
  • 16,440
  • 2
  • 27
  • 44