[Python-Dev] Pathlib enhancments - method name only

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Apr 10 02:38:35 EDT 2016

Eric Snow wrote:
> All this matters because it impacts the value returned from
> __ospath__().  Should it return the string representation of the path
> for the current OS or some standardized representation?

What standardized representation? I'm not aware of such
a thing.

> I'd expect
> the former.  However, if that is the expectation then something like
> pathlib.PureWindowsPath will give you the wrong thing if your current
> OS is linux.

No, you should get the representation corresponding to
the kind of path object you started with. If you're
working with Windows path objects on a Unix system,
they must be representing something on some Windows
system somewhere, not the one you're running the code
on. The only reason to ask for a string representation
of such a path is for use by that other system.

I don't think it even makes sense to ask for a Unix
representation of a Windows path or vice versa, because
the semantics are different. How do you translate a
Windows drive letter into Unix? What drive letter do
you use for an absolute Unix path?


More information about the Python-Dev mailing list