On Wed, 13 Apr 2016 at 09:19 Fred Drake <f...@fdrake.net> wrote: > On Wed, Apr 13, 2016 at 11:09 AM, Ethan Furman <et...@stoneleaf.us> wrote: > > - a single os.fspath() with an allow_bytes parameter > > (mostly True in os and os.path, mostly False everywhere > > else) > > -0 > > > - a str-only os.fspathname() and a str/bytes os.fspath() > > +1 on using separate functions. > > > I'm partial to the first choice as it is simplicity itself to know when > > looking at it if bytes might be coming back by the presence or absence > of a > > second argument to the call; otherwise one has to keep straight in one's > > head which is str-only and which might allow bytes (I'm not very good at > > keeping similar sounding functions separate -- what's the difference > between > > shutil.copy and shutil.copy2? I have to look it up every time). > > 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) > > Names like os.fspath() and os.fssyspath() seem good to me. > -Brett
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com