[Python-ideas] Working with Path objects: p-strings?
Brett Cannon
brett at python.org
Tue Mar 29 18:49:47 EDT 2016
On Tue, 29 Mar 2016 at 15:41 Koos Zevenhoven <k7hoven at gmail.com> wrote:
>
> >> On Mar 30, 2016 01:07, "Ethan Furman" wrote:
> >
> >
> >>> Please provide an example of both a relative and an absolute path
> >>> construction using `P`.
> >>
> >>
> >> P/'relative/path'
> >>
> >> P/'/absolute/path'
> >
> >
> > Thank you.
> >
> > So under this system a relative path appears with one leading slash, and
> an absolute path appears with two leading slashes.
> >
> > Can't say I'm a fan. :(
> >
>
> I'll have to agree. But to be fair, Greg wrote something like 'a suitable
> seed object' so we could for ex. have P=PathSeed(), and use another
> operator.
>
> P@'rel/path'
>
> P@'/abs/path'
>
> Dunno.
>
If you are constructing a new object then you don't need to limit yourself
to a single one. You could use A for absolute paths and R for relative
paths:
R/'relative'/'path'
A/'absolute'/'path'
Or even P.absolute and P.relative:
P.relative/'relative'/'path'
P.absolute/'absolute'/'path'
And you could even go as far as make one the default and the other not to
promote one over the other:
P.relative/'relative'/'path'
P/'absolute'/'path'
-Brett
> -K at mobile
> _______________________________________________
> 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/20160329/ae9e7edb/attachment-0001.html>
More information about the Python-ideas
mailing list