[Python-Dev] Pathlib enhancments - method name only
ncoghlan at gmail.com
Mon Apr 11 02:20:05 EDT 2016
On 11 April 2016 at 01:50, Donald Stufft <donald at stufft.io> wrote:
>> On Apr 10, 2016, at 2:43 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> This does raise a concrete API design question: how should
>> PurePath.__fspath__ behave when called on a mismatched OS?
> I think that PurePath.__fspath__ should return a string. There’s no
> reason why we can’t in my opinion and doing so just limits the usefulness
> of the method. For instance, it’d prevent it from being possible to
> serialize a pure windows path and send it over the wire to a process running
> on a Windows machine, like say if you have a build master running on Linux
> and a build slave running on Windows.
Yeah, given that you have to go out of your way to create a path
object for an alternate platform, this makes sense - the "I know what
I'm doing" indicator is calling pathlib.Pure[Windows|Posix]Path
instead of ""pathlib.PurePath in the first place, and so __fspath__
can just do its thing as a pure text-based operation, without worrying
about the current platform.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev