[Python-Dev] Defining a path protocol

Chris Angelico rosuav at gmail.com
Thu Apr 7 08:11:34 EDT 2016

On Thu, Apr 7, 2016 at 9:44 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Excellent!  Narrowing the field then to:
> __fspath__
> __os_path__
> Step right up!  Cast yer votes!

+0.9 for __fspath__; I'd prefer a one-word name, but with __path__ out
of the running (which I agree with), there's no other obvious word.
__fspath__ is a close second.

-1 for __os_path__, unless it's reasonable to justify it as "most of
the standard library uses Path objects, but os.path uses strings, so
before you pass a Path to anything in os.path, you call path.ospath()
on it, which calls __os_path__()". And that seems a bit hairy and
roundabout; what it's _really_ doing is giving you back a string, and
that has little to do with os.path.


More information about the Python-Dev mailing list