Behaviour of os.path.join

Chris Angelico rosuav at gmail.com
Wed May 27 04:55:20 EDT 2020


On Wed, May 27, 2020 at 6:50 PM Barry Scott <barry at barrys-emacs.org> wrote:
>
>
>
> > On 26 May 2020, at 18:01, BlindAnagram <blindanagram at nowhere.com> wrote:
> >
> > On 26/05/2020 17:09, Stefan Ram wrote:
> >> Mats Wichmann <mats at python.org> writes:
> >>> an absolute path is one that starts with the pathname separator.
> >>
> >>  The Python Library Reference does not use the term
> >>  "pathname separator". It uses "directory separator"
> >>  (os.sep) and "filename separator" ('/' on Unix).
> >>
> >>  On Windows:
> >>
> >> |>>> import pathlib
> >> |>>> import os
> >> |>>> pathlib.PureWindowsPath('\\').is_absolute()
> >> |False
> >> |>>> pathlib.PureWindowsPath(os.sep).is_absolute()
> >> |False
> >> |>>> pathlib.PureWindowsPath('/').is_absolute()
> >> |False
> >
> > Thanks, that seems to suggest that there is an issue and that I should
> > hence submit this as an issue.
>
> Can you post the a link to the issue please?
>
> I note that
>
> >>> pathlib.Path('/').is_absolute()
> False
> >>> pathlib.Path('/').resolve().is_absolute()
> True
> >>>
>
> The resolve() is required and I think should not be required.
>

Have a look at the difference between the original Path and the
resolved one, and see if there's a difference there. I suspect that
resolve() is adding the current drive onto that path and thus making
it fully absolute.

ChrisA


More information about the Python-list mailing list