[Python-Dev] File system path PEP, part 2 (original) (raw)

Random832 random832 at fastmail.com
Fri May 13 11:25:26 EDT 2016


On Fri, May 13, 2016, at 07:00, Steven D'Aprano wrote:

- but os.fspath() will only return str;

- and os.fspathb() will only return bytes;

And raise an exception if fspath returns the other, I suppose. What's the use case for these functions? When would I call them rather than fsdecode and fsencode? (assuming the latter will support the path protocol - I've got more objections if they're not going to)

Also, what happens if you pass a string to os.fspath? Statements like "str will not implement fspath" have thus far been light on details of what functions will accept "str or path-like-object-whose-__fspath__returns-str" and which ones will only accept the latter (and what, if any, will continue to only accept the former). If no-one's supposed to directly call dunder methods, and os.fspath accepts str, then what difference does it make whether this is implemented by having a special case within os.fspath or by calling str.fspath?



More information about the Python-Dev mailing list