[Python-ideas] Better stdlib support for Path objects

Georg Brandl g.brandl at gmx.net
Mon Oct 6 23:19:37 CEST 2014


On 10/06/2014 10:20 PM, Juancarlo Añez wrote:
> 
> On Mon, Oct 6, 2014 at 2:39 PM, Terry Reedy
> <tjreedy at udel.edu
> <mailto:tjreedy at udel.edu>> wrote:
> 
>     To me, the first question to me is whether we 'believe' in pathlib
>     enough to really support it in the stdlib and encourage its use.
> 
> 
> os.path is cumbersome (horrible?) when compared to pathlib.

Horrible? Please.

> The issue is prevalent throughout stdlib. For example, json won't take a
> pathlib.Path, so you have to pass str(mypath).

That it is prevalent is exactly the problem with fixing it, in my opinion.

This is like the situation with context managers.  We've taken about 3-4
minor releases to add "with" support to objects that can logically support
it.  Nobody remembers this, so people have to refer to the docs (or the code)
to see if and when e.g. smtplib.SMTP gained "with" support.

However, the context managers are a few dozen classes at most.  With paths,
there are hundreds of APIs that would have to be updated to take Paths
in the stdlib alone.  Granted, a good portion would probably work fine since
they only pass through paths to lower level APIs, but still every one has to
be checked.  Going by precedent, that's not something that we would be able
to do consistently, even throughout several releases.  (Another precedent is
Argument Clinic.)

cheers,
Georg



More information about the Python-ideas mailing list