Message338160
The drive is retained when a rooted path is joined to a drive-absolute or UNC-absolute path. This is documented behavior [1]:
When several absolute paths are given, the last is taken as an
anchor (mimicking os.path.join()’s behaviour):
>>> PurePath('/etc', '/usr', 'lib64')
PurePosixPath('/usr/lib64')
>>> PureWindowsPath('c:/Windows', 'd:bar')
PureWindowsPath('d:bar')
However, in a Windows path, changing the local root doesn’t
discard the previous drive setting:
>>> PureWindowsPath('c:/Windows', '/Program Files')
PureWindowsPath('c:/Program Files')
If you want to simply append directories to a path, use a relative path. For example:
>>> Path('C:/Program Files') / Path('one/two/three.exe')
WindowsPath('C:/Program Files/one/two/three.exe')
[1]: https://docs.python.org/3/library/pathlib.html#pathlib.PurePath |
|
Date |
User |
Action |
Args |
2019-03-18 04:08:03 | eryksun | set | recipients:
+ eryksun, paul.moore, tim.golden, zach.ware, steve.dower, Mike Davies |
2019-03-18 04:08:02 | eryksun | set | messageid: <1552882082.98.0.472111191944.issue36334@roundup.psfhosted.org> |
2019-03-18 04:08:02 | eryksun | link | issue36334 messages |
2019-03-18 04:08:02 | eryksun | create | |
|