[Python-ideas] Working with Path objects: p-strings?

Chris Angelico rosuav at gmail.com
Fri Mar 25 19:56:26 EDT 2016


On Sat, Mar 26, 2016 at 8:59 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Also, it would be stretching the string-prefix concept considerably.
> Currently, the prefixes just represent different ways of specifying
> a string -- the end result is still always an instance of str.
> In this proposal, it would be a different type of object with
> greatly different behaviour.

There's b"..." vs u"...", which do represent entirely different
objects, plus f"..." which isn't even a literal at all, but more like
a special syntax for an expression (it's more akin to a list display
than to a string literal). So there is precedent.

If Path objects had universal support in the stdlib *and* significant
support in third-party libraries, they could be the one obvious way to
do pretty much anything involving paths. At the moment, they're a cute
[1] way of getting just slightly more functionality than strings give.
The question is: Should syntax precede or follow extensive usage?

ChrisA
[1] Overloading division doesn't really do anything for you, other
than the way it looks similar to the normal path sep. It's really more
of a concatenation operation, which would normally be + not /.


More information about the Python-ideas mailing list