[Python-Dev] file system path protocol PEP

Ethan Furman ethan at stoneleaf.us
Thu May 12 12:56:39 EDT 2016


On 05/12/2016 09:26 AM, Sven R. Kunze wrote:
> On 12.05.2016 17:42, Ethan Furman wrote:
>> On 05/12/2016 01:31 AM, Sven R. Kunze wrote:

>>> I think the "Rationale" section ignores the fact the Path also supports
>>> the .path attribute now. Which indeed defines a common interface between
>>> path objects.
>>
>> The version of Python that has Path.path has not been released yet.
>> And even so, .path is not a "common interface" as neither str nor
>> bytes have it, and they also are used as path objects.
>
> str and bytes will receive the __fspath__ attribute when this PEP is
> accepted?

No, they won't.  The __fspath__ protocol will reduce the rich path 
object down to a str/bytes object.

One could argue that a .path attribute is similar, but consider:  if you 
are handed a random object with a .path attribute, how certain can you 
be that it represents a file system path?  Contrariwise, how certain can 
you be of an object that has __fspath__?

At any rate, we seem to be down to the details of os.fspath() so I don't 
see any reason to discuss .path any further.

--
~Ethan~


More information about the Python-Dev mailing list