Behaviour of os.path.join

BlindAnagram blindanagram at nowhere.com
Tue May 26 10:56:02 EDT 2020


I came across an issue that I am wondering whether I should report as an
issue.  If I have a directory, say:

  base='C:\\Documents'

and I use os.path.join() as follows:

  join(base, '..\\..\\', 'build', '')

I obtain as expected from the documentation:

'C:\\Documents\\..\\..\\build\\'

But if I try to make the directory myself (as I tried first):

  join(base, '..\\..\\', 'build', '\\')

I obtain:

'C:\\'

The documentation says that an absolute path in the parameter list for
join will discard all previous parameters but '\\' is not an absoute path!

Moreover, if I use

  join(base, '..\\..\\', 'build', os.sep)

I get the same result.

This seems to me to be a bug that I should report but to avoid wasting
developer time I wanted to hear what others feel about this.


More information about the Python-list mailing list