Path-like objects in the standard library
Paul Moore
p.f.moore at gmail.com
Fri Aug 24 05:28:35 EDT 2018
On Fri, 24 Aug 2018 at 09:57, Torsten Bronger
<bronger at physik.rwth-aachen.de> wrote:
>
> Hallöchen!
>
> Path-like objects are accepted by all path-processing functions in
> the standard library since Python 3.6. Unfortunately, this is not
> made explicit everywhere. In particular, if I pass a Path in the
> first argument of subprocess.run, do I use an implementation detail
> of CPython? Because on
> https://docs.python.org/3.6/library/subprocess.html, only for the
> cwd argument the acceptance of Paths is stated explicitly.
>
> The same goes for all functions in the shutil module.
> https://docs.python.org/3.6/library/shutil.html does not mention the
> path-like protocol anywhere, but the CPython modules seem to accept
> them anyway.
I would imagine that doc fixes would be gratefully accepted. Or if
they are rejected, that rejection would be confirmation that the
support is intended as an implementation detail (and a fix to the
documentation to explicitly state that would be reasonable).
Personally, I'd expect that the intention is that you can rely on it.
Paul
More information about the Python-list
mailing list