Eryk Sun added the comment:
os.path.join and pathlib are working as designed and documented. Similarly in
POSIX we have the following:
>>> p = os.path.join("/123/345", "/", "folder///filename.bin")
>>> print(p)
/folder///filename.bin
>>> print(os.path.normpath(p))
Roffild added the comment:
It is necessary to assemble a single path from several lines depending on the
OS.
It is logical to expect behavior in Java.
https://docs.oracle.com/javase/8/docs/api/java/nio/file/Paths.html
Converts a path string, or a sequence of strings that when joined form a
Eric V. Smith added the comment:
As far as which path components are returned, I think this is working as
designed. The documentation for os.path.join says:
"""
If a component is an absolute path, all previous components are thrown away and
joining continues from the absolute path component.
New submission from Roffild :
Code:
import os
print(os.path.join("C:/123\\345", "\\", "folder///filename.bin"))
import pathlib
print(pathlib.PureWindowsPath("C:/123\\345", "\\", "folder///filename.bin"))
Result:
C:\folder///filename.bin
C:\folder\filename.bin
Expected result for Windows: