[Python-ideas] tweaking the file system path protocol

Serhiy Storchaka storchaka at gmail.com
Mon May 29 03:55:29 EDT 2017


29.05.17 00:33, Wolfgang Maier пише:
> The path protocol does 
> *not* use __fspath__ as an indicator that an object's str-representation 
> is intended to be used as a path. If you had wanted this, the PEP should 
> have defined __fspath__ not as a method, but as a flag and have the 
> protocol check that flag, then call __str__ if appropriate.

__fspath__ is a method because there is a need to support bytes paths. 
__fspath__() can return a bytes object, str() can't.



More information about the Python-ideas mailing list