<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, 13 Apr 2016 at 09:19 Fred Drake <<a href="mailto:fred@fdrake.net">fred@fdrake.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Apr 13, 2016 at 11:09 AM, Ethan Furman <<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>> wrote:<br>
> - a single os.fspath() with an allow_bytes parameter<br>
>   (mostly True in os and os.path, mostly False everywhere<br>
>   else)<br>
<br>
-0<br>
<br>
> - a str-only os.fspathname() and a str/bytes os.fspath()<br>
<br>
+1 on using separate functions.<br>
<br>
> I'm partial to the first choice as it is simplicity itself to know when<br>
> looking at it if bytes might be coming back by the presence or absence of a<br>
> second argument to the call; otherwise one has to keep straight in one's<br>
> head which is str-only and which might allow bytes (I'm not very good at<br>
> keeping similar sounding functions separate -- what's the difference between<br>
> shutil.copy and shutil.copy2?  I have to look it up every time).<br>
<br>
I do the same, but... this is one of those cases where a caller will<br>
usually be passing a constant directly. If passed as a positional<br>
argument, it'll just be confusing ("what's True?" is my usual reaction<br>
to a Boolean positional argument).</blockquote><div><br></div><div>It would be keyword-only so this isn't even a possibility.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> If passed as a keyword argument<br>
with a descriptive name, it'll be longer than I'd like to see:<br>
<br>
    path_str = os.fspath(path, allow_bytes=True)<br></blockquote><div><br></div><div>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:</div><div><br></div><div>    path_str = os.fspath(path)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Names like os.fspath() and os.fssyspath() seem good to me.<br></blockquote><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">-Brett </span><br></div></div></div>