[Python-ideas] Updated PEP 428 (pathlib)

Antoine Pitrou solipsis at pitrou.net
Thu Mar 7 11:24:33 CET 2013


Le Tue, 05 Mar 2013 16:58:57 +0200,
Serhiy Storchaka <storchaka at gmail.com> a
écrit :
> On 05.03.13 09:23, Antoine Pitrou wrote:
> > On Tue, 05 Mar 2013 00:33:48 +0100
> > Jan Kaliszewski <zuo at chopin.edu.pl> wrote:
> >> 1. Ad:
> >>       >>> PurePosixPath('/usr/bin/python').relative('/etc')
> >>       Traceback (most recent call last):
> >>         ...
> >>       ValueError: ...
> >>
> >> Shouldn't this particular operation return
> >> "PurePosixPath('/etc/../usr/bin/python')"?
> >
> > Think what happens if /etc is a symlink to /var/etc.
> > (not very likely to happen for /etc, but likely to happen in the
> > general case)
> 
> posixpath.relpath('/usr/bin/python', '/etc') returns 
> '../usr/bin/python'. Perhaps pathlib should have an option to provide 
> such compatible behavior.

I don't think so, since the behaviour is broken in the first place.

> P.S. Pathlib implementation has relative_to() method. relative()
> method exists too but looks as unrelated.

Not in the "pep428" branch.

Regards

Antoine.





More information about the Python-ideas mailing list