[Python-Dev] Pathlib enhancements - acceptable inputs and outputs for fspath and os.fspath() (original) (raw)

Ethan Furman ethan at stoneleaf.us
Thu Apr 14 14:39:43 EDT 2016


On 04/13/2016 02:37 PM, Victor Stinner wrote:

I'm not a big fan of a flag parameter to change the return type of a function. Usually, two functions are preferred. In the os module we have getcwd/getcwdb for example. I don't know if it's a good example

I think of os.fspath() as more of a filter/reduce operation:

The purpose of os.fspath() (at least the one I'm arguing for ;) is to distil its inputs to the lowest common denominator, and no lower -- which is either str for string-based path objects, or bytes for bytes-based path objects.

-- Ethan



More information about the Python-Dev mailing list