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

Ethan Furman ethan at stoneleaf.us
Wed Apr 13 13:06:33 EDT 2016

On 04/13/2016 09:58 AM, Brett Cannon wrote:> On Wed, 13 Apr 2016 at 
09:19 Fred Drake wrote:

 >> I do the same, but... this is one of those cases where a caller will
 >> usually be passing a constant directly. If passed as a positional
 >> argument, it'll just be confusing ("what's True?" is my usual
 >> reaction to a Boolean positional argument).
 > It would be keyword-only so this isn't even a possibility.
 >> If passed as a keyword argument
 >> with a descriptive name, it'll be longer than I'd like to see:
 >>      path_str = os.fspath(path, allow_bytes=True)
 > I think the expectation that the number of people actually directly
 > calling this function with that argument specified is going to be
 > rather small, so the common-case will simply be:
 >      path_str = os.fspath(path)

That is certainly my expectation.  :)

 >> Names like os.fspath() and os.fssyspath() seem good to me.

A single function is definitely my preference, but if that's not 
possible then I'm fine with that pair of names.


More information about the Python-Dev mailing list