[Python-ideas] Better stdlib support for Path objects

Wes Turner wes.turner at gmail.com
Tue Oct 7 20:25:44 CEST 2014


Does path.py have different performance in this respect?

I like the Path.isdir(), Path.walk() methods; but maybe not for everyone.

Way OT, but similar support for URIs (e.g. URLObject) would likely need to
take a similar approach:
http://www.reddit.com/r/Python/comments/1r7h1t/python_objects_for_working_with_urls_and_uris/
On Oct 6, 2014 12:50 PM, "Barry Warsaw" <barry at python.org> wrote:

> Over in issue 22570, I lament the fact that while pathlib is awesome, its
> wider support in the stdlib is pretty sparse.  I've tried to convert parts
> of
> a medium sized Python 3 application from os.path to pathlib and found this
> lack of support rather demotivating.  Yes, it's fairly easy to wrap Path
> objects in str() to pass them to stdlib methods that expect only strings,
> but
> it's a lot of work in user code and I find that the resulting str()s are
> distracting.  It's a disincentive.
>
> Antoine provided a link to a previous discussion[*] but that didn't go very
> far.
>
> One simple solution would be to sprinkle str() calls in various stdlib
> methods, but I'm not sure if that would fail miserably in the face of bytes
> paths (if the original stdlib API even accepts bytes paths).  The
> suggestion
> in the issue is to add a "path protocol" and the referenced article
> suggests
> .strpath and .bytespath.  OTOH, isn't str() and bytes() enough?
>
> I don't have any other brilliant ideas, but I opened the issue and am
> posting
> here to see if we can jump start another discussion for Python 3.5.  I'd
> *like* to use more Paths, but not at the expense of my own code's
> readability.
> Yes, I'd sacrifice a bit of readability in the stdlib, especially if that
> would cover more use cases.
>
> Cheers,
> -Barry
>
> [*] https://mail.python.org/pipermail/python-ideas/2014-May/027869.html
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141007/b631a04e/attachment-0001.html>


More information about the Python-ideas mailing list