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

Nathan Schneider neatnate at gmail.com
Wed Mar 30 08:36:17 EDT 2016


On Wed, Mar 30, 2016 at 4:25 AM, Random832 <random832 at fastmail.com> wrote:

> On Tue, Mar 29, 2016, at 17:39, Ethan Furman wrote:
> > On 03/29/2016 02:30 PM, Greg Ewing wrote:
> > > Paul Moore wrote:
> > >>
> > >> P(wherever)/youwant/togo
> > >
> > > If P were a suitable seed object, this could be
> > >
> > >    P/wherever/youwant/togo
> >
> > An interesting idea, but how would you differentiate between relative
> > and absolute paths?
>
> Path.ROOT/absolute/path
> Path.DOT/relative/path
>

How about:

Path/absolute/path
Path%relative/path [think: % as the Unix shell prompt]

I also like the idea of being able to do

Path/~homesubdir/path

as an alias for

Path/'~'/homesubdir/path

Apart from the above, the user would have to know to quote special path
characters like ~ and . and trailing / to avoid a syntax error:

Path/'~'
Path/'..'/relative/path
Path/absolute/path/'/' [in rare cases where the trailing slash is necessary]


Nathan

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160330/05357c17/attachment.html>


More information about the Python-ideas mailing list