
May 29, 2017
7:55 a.m.
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.