[issue44452] Allow paths to be joined without worrying about a leading slash

2021-11-26 Thread Eryk Sun
Eryk Sun added the comment: > and b / a gives me WindowsPath('/a/b'). So I'm like "ok, a seems > like absolute, I will test for that" but on Windows a.is_absolute() > is False. Path.is_absolute() is true if a path has a `root` and, for a Windows path, also a `drive`. In C++, the filesystem::

[issue44452] Allow paths to be joined without worrying about a leading slash

2021-11-26 Thread lutecki
lutecki added the comment: So how this should work? I'm testing this simple example on Windows: a = Path("/a/b") b = Path("c/d") and b / a gives me WindowsPath('/a/b'). So I'm like "ok, a seems like absolute, I will test for that" but on Windows a.is_absolute() is False. ??? Regards -

[issue44452] Allow paths to be joined without worrying about a leading slash

2021-09-10 Thread Sylvain Marie
Sylvain Marie added the comment: +1 on this, I am totally in line with the original post. The / operator semantics should not imply any notion of drive or of "cd" command on a shell. It should simply stick to "concatenate", i.e. "create child path" (and actually this is what the doc states

[issue44452] Allow paths to be joined without worrying about a leading slash

2021-06-27 Thread Zbyszek Jędrzejewski-Szmek
Zbyszek Jędrzejewski-Szmek added the comment: > I can see the need for generalized 'drive' support that sets an arbitrary > path prefix as the 'drive'. For example, if "/var/tmp/instroot" is a 'drive', > then joining it to "/some/path" returns "/var/tmp/instroot/some/path". > However, subsequ

[issue44452] Allow paths to be joined without worrying about a leading slash

2021-06-27 Thread Eryk Sun
Eryk Sun added the comment: > I was thinking about about a case where paths are resolved relative > to a container root in a filesystem. I can see the need for generalized 'drive' support that sets an arbitrary path prefix as the 'drive'. For example, if "/var/tmp/instroot" is a 'drive', th

[issue44452] Allow paths to be joined without worrying about a leading slash

2021-06-27 Thread Zbyszek Jędrzejewski-Szmek
Zbyszek Jędrzejewski-Szmek added the comment: > It doesn't make sense to "concatenate" one absolute path to another. Please see the original description of the issue, or Serhiy's example. I was thinking about about a case where paths are resolved relative to a container root in a filesystem.

[issue44452] Allow paths to be joined without worrying about a leading slash

2021-06-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I understand why this problem arose. If you parse an HTTP URL, its path always starts with "/" if not empty. And you usually want to interpret it as a relative to some base directory. But lstrip('/') works well here. In any case you need to have some valid

[issue44452] Allow paths to be joined without worrying about a leading slash

2021-06-26 Thread Vedran Čačić
Vedran Čačić added the comment: It doesn't make sense to "concatenate" one absolute path to another. / has a simple explanation: if you start at /foo, and then do cd bar, you'll end up in /foo/bar. But if you start at /foo, and then do cd /bar, you'll end up in /bar. You mean, some of your us

[issue44452] Allow paths to be joined without worrying about a leading slash

2021-06-23 Thread Eric V. Smith
Eric V. Smith added the comment: You should bring this up on the python-ideas mailing list if you want some discussion. -- nosy: +eric.smith ___ Python tracker ___ __

[issue44452] Allow paths to be joined without worrying about a leading slash

2021-06-18 Thread Zbyszek Jędrzejewski-Szmek
New submission from Zbyszek Jędrzejewski-Szmek : pathlib.Path.__truediv__(), i.e. pathlib.Path.joinpath() is surprising when the second argument starts with a slash. >>> pathlib.Path('/foo') / '/bar' >>> PosixPath('/bar') I know that this follows the precedent set by os.path.join(), and probab