Suggestion for pathlib: differentiate explicit and implicit local paths (pathlib.StrictPath?)

Related discussion: Pathlib: preserve trailing slash

An exchange I found super informative:

Pathlib’s handling of . segments, trailing slashes, etc, isn’t some accident or optional feature - it’s at the very core of what pathlib is and does.

And so from my perch in Pedantry Corner, I might argue that Python doen’t really have an object-oriented version of os.path, and existing code using os.path can’t be safely ported to pathlib without some care being taken to avoid data loss. Honestly I don’t feel good about this, and I’m looking at whether @departure3560’s earlier suggestion that Path subclasses a new StrictPath class has legs. It fits rather well with my plans for the pathlib ABCs, which should result in a very straightforward/obvious implementation. I’ll share a prototype when I have one.

3 Likes