Re: Behaviour of os.path.join

2020-05-28 Thread Eryk Sun
On 5/28/20, Roel Schroeven wrote: > Eryk Sun schreef op 28/05/2020 om 15:51: >> On 5/27/20, Chris Angelico wrote: >>> On Thu, May 28, 2020 at 7:07 AM BlindAnagram >>> wrote: You can define a path however you want but it won't change the fact that on Windows a path that ends in '\\' is

Re: Behaviour of os.path.join

2020-05-28 Thread MRAB
On 2020-05-28 22:34, Terry Reedy wrote: On 5/28/2020 9:19 AM, Eryk Sun wrote: On 5/26/20, BlindAnagram wrote: 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 paramet

Re: Behaviour of os.path.join

2020-05-28 Thread Roel Schroeven
BlindAnagram schreef op 28/05/2020 om 11:00: On 27/05/2020 23:39, Roel Schroeven wrote: I find no hints of adding a backslash at the end to indicate directories. If you can point me to convincing evidence in the documentation I'll change my mind. And if you find a counterexample, I will change

Re: Behaviour of os.path.join

2020-05-28 Thread Roel Schroeven
Eryk Sun schreef op 28/05/2020 om 15:51: On 5/27/20, Chris Angelico wrote: On Thu, May 28, 2020 at 7:07 AM BlindAnagram wrote: You can define a path however you want but it won't change the fact that on Windows a path that ends in '\\' is inherently a path to a directory. Citation needed.

Re: Behaviour of os.path.join

2020-05-28 Thread Terry Reedy
On 5/28/2020 9:19 AM, Eryk Sun wrote: On 5/26/20, BlindAnagram wrote: 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 previou

Re: Behaviour of os.path.join

2020-05-28 Thread Grant Edwards
On 2020-05-27, Roel Schroeven wrote: > I find no hints of adding a backslash at the end to indicate directories. I suspect that, like Unix, that's not an OS/filesystem thing but merely a convention used by some user space applications to allow the user to provide an additional hint as to his int

Re: Behaviour of os.path.join

2020-05-28 Thread BlindAnagram
On 27/05/2020 23:39, Roel Schroeven wrote: > I find no hints of adding a backslash at the end to indicate directories. > > If you can point me to convincing evidence in the documentation I'll > change my mind. See the post from Eryk Sun, later in this thread. -- https://mail.python.org/mailman/

Re: Behaviour of os.path.join

2020-05-28 Thread Eryk Sun
On 5/28/20, BlindAnagram wrote: > > Thank you for making the effort to answer a number of issues raaised in > this thread. I much appreciate your input. For a more practical POV, see the topic on "File System Navigation" [1] for the C++ standard API. In the C++ standard library, trailing slashe

Re: Behaviour of os.path.join

2020-05-28 Thread BlindAnagram
On 28/05/2020 14:51, Eryk Sun wrote: > On 5/27/20, Chris Angelico wrote: >> On Thu, May 28, 2020 at 7:07 AM BlindAnagram >> wrote: >>> You can define a path however you want but it won't change the fact that >>> on Windows a path that ends in '\\' is inherently a path to a directory. >> >> Citati

Re: Behaviour of os.path.join

2020-05-28 Thread Eryk Sun
On 5/27/20, Chris Angelico wrote: > On Thu, May 28, 2020 at 7:07 AM BlindAnagram > wrote: >> You can define a path however you want but it won't change the fact that >> on Windows a path that ends in '\\' is inherently a path to a directory. > > Citation needed. See [MS-FSA] 2.1.5.1 Server Reque

Re: Behaviour of os.path.join

2020-05-28 Thread Eryk Sun
On 5/26/20, BlindAnagram wrote: > > 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

Re: Behaviour of os.path.join

2020-05-28 Thread BlindAnagram
On 27/05/2020 23:39, Roel Schroeven wrote: > BlindAnagram schreef op 27/05/2020 om 22:55: >> On 27/05/2020 18:42, Roel Schroeven wrote: >>> BlindAnagram schreef op 27/05/2020 om 18:53: Its not my bug to fix - the semantics of what I send is very clear on any Windows system. >>> >>> That's

Re: Behaviour of os.path.join

2020-05-27 Thread Chris Angelico
On Thu, May 28, 2020 at 7:07 AM BlindAnagram wrote: > You can define a path however you want but it won't change the fact that > on Windows a path that ends in '\\' is inherently a path to a directory. Citation needed. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Behaviour of os.path.join

2020-05-27 Thread Roel Schroeven
BlindAnagram schreef op 27/05/2020 om 22:55: On 27/05/2020 18:42, Roel Schroeven wrote: BlindAnagram schreef op 27/05/2020 om 18:53: Its not my bug to fix - the semantics of what I send is very clear on any Windows system. That's the first time I see any mention of those semantics, and I've b

Re: Behaviour of os.path.join

2020-05-27 Thread DL Neil via Python-list
... Again, a pathname is never inherently a directory or a file. See previous contribution: until YOU define YOUR arena of operations, it will be difficult to select the correct tool or library - or for others to assist you. If dealing with strings (which happen to look as if they are fil

Re: Behaviour of os.path.join

2020-05-27 Thread BlindAnagram
On 27/05/2020 18:42, Roel Schroeven wrote: > BlindAnagram schreef op 27/05/2020 om 18:53: >> Its not my bug to fix - the semantics of what I send is very clear on >> any Windows system. > > That's the first time I see any mention of those semantics, and I've > been using Windows since the Windows

Re: Behaviour of os.path.join

2020-05-27 Thread BlindAnagram
On 27/05/2020 18:37, Roel Schroeven wrote: > BlindAnagram schreef op 27/05/2020 om 18:39: >> On 27/05/2020 16:49, Rhodri James wrote: >>> On 27/05/2020 16:12, BlindAnagram wrote: I'm sorry that you don't believe me but all I know is how I intend the path to be used.  And the os.path func

Re: Behaviour of os.path.join

2020-05-27 Thread Ben Bacarisse
Roel Schroeven writes: > Ben Bacarisse schreef op 27/05/2020 om 17:53: >> There is well-known (*nix) software that relies on a/b/c/ meaning >> something different to a/b/c but I don't know anyone who thinks this is >> a good idea. It causes no end of confusion. > > rsync? I always have to look u

Re: Behaviour of os.path.join

2020-05-27 Thread Chris Angelico
On Thu, May 28, 2020 at 6:14 AM Roel Schroeven wrote: > > Ben Bacarisse schreef op 27/05/2020 om 17:53: > > There is well-known (*nix) software that relies on a/b/c/ meaning > > something different to a/b/c but I don't know anyone who thinks this is > > a good idea. It causes no end of confusion.

Re: Behaviour of os.path.join

2020-05-27 Thread Ben Bacarisse
BlindAnagram writes: > On 27/05/2020 16:53, Ben Bacarisse wrote: >> As it should. Relying on a trailing \ having the right effect is >> brittle to say the least. > > In my case less brittle than leaving it out. Brittle does not mean broken. I know you can fix it by making sure the trailing \

Re: Behaviour of os.path.join

2020-05-27 Thread Roel Schroeven
Ben Bacarisse schreef op 27/05/2020 om 17:53: There is well-known (*nix) software that relies on a/b/c/ meaning something different to a/b/c but I don't know anyone who thinks this is a good idea. It causes no end of confusion. rsync? I always have to look up whether or not I need to use a tra

Re: Behaviour of os.path.join

2020-05-27 Thread Roel Schroeven
BlindAnagram schreef op 27/05/2020 om 18:53: Its not my bug to fix - the semantics of what I send is very clear on any Windows system. That's the first time I see any mention of those semantics, and I've been using Windows since the Windows 3.1 days (and MS-DOS before that, since 3.2 IIRC).

Re: Behaviour of os.path.join

2020-05-27 Thread Roel Schroeven
BlindAnagram schreef op 27/05/2020 om 18:39: On 27/05/2020 16:49, Rhodri James wrote: On 27/05/2020 16:12, BlindAnagram wrote: I'm sorry that you don't believe me but all I know is how I intend the path to be used.  And the os.path functions aren't helpful here when they actually_change_  the m

Re: Behaviour of os.path.join

2020-05-27 Thread Andrew Jaffe
Dear all, \On 26/05/2020 15:56, BlindAnagram wrote: 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 d

Re: Behaviour of os.path.join

2020-05-27 Thread Beverly Pope
I wasn’t going to say anything because I haven’t used MS Windows for years. The OP wants to add a path separator at the end of a path. Why the OP wants to do that doesn’t concern me. OTOH, as others have already mentioned, the documentation explicitly says, "If a component is an absolute path

Re: Behaviour of os.path.join

2020-05-27 Thread Rhodri James
On 27/05/2020 17:39, BlindAnagram wrote: I believe by attempting to make the directory I send absolute with abspath() and then copying a file to this path. They expected this to copy the file into the directory with its original name but instead it copies it to the file that abspath 'kindly' con

Re: Behaviour of os.path.join

2020-05-27 Thread BlindAnagram
On 27/05/2020 16:53, Ben Bacarisse wrote: > BlindAnagram writes: > >> On 27/05/2020 13:30, Ben Bacarisse wrote: >>> BlindAnagram writes: >>> >>>> The issue that I raised here was whether the behaviour of os.path.join() >>>> in treating th

Re: Behaviour of os.path.join

2020-05-27 Thread BlindAnagram
On 27/05/2020 16:49, Rhodri James wrote: > On 27/05/2020 16:12, BlindAnagram wrote: >> I'm sorry that you don't believe me but all I know is how I intend the >> path to be used.  And the os.path functions aren't helpful here when >> they actually_change_  the meanings of paths on Windows: >> f

Re: Behaviour of os.path.join

2020-05-27 Thread Ben Bacarisse
BlindAnagram writes: > On 27/05/2020 13:30, Ben Bacarisse wrote: >> BlindAnagram writes: >> >>> The issue that I raised here was whether the behaviour of os.path.join() >>> in treating the Windows directory separator '\\' as an absolute path >>

Re: Behaviour of os.path.join

2020-05-27 Thread Rhodri James
On 27/05/2020 16:12, BlindAnagram wrote: I'm sorry that you don't believe me but all I know is how I intend the path to be used. And the os.path functions aren't helpful here when they actually_change_ the meanings of paths on Windows: fp= "C:\\Documents\finance\\" abspath(fp) 'C:\\Documents

Re: Behaviour of os.path.join

2020-05-27 Thread BlindAnagram
On 27/05/2020 14:53, Rhodri James wrote: > On 27/05/2020 14:41, BlindAnagram wrote: >> That is true if you know for sure how your path will be used. >> >> But if you don't, there is a world of difference between passing the >> paths 'name' and 'name\\' on for others to use. And in this situation it

Re: Behaviour of os.path.join

2020-05-27 Thread Rhodri James
On 27/05/2020 14:41, BlindAnagram wrote: That is true if you know for sure how your path will be used. But if you don't, there is a world of difference between passing the paths 'name' and 'name\\' on for others to use. And in this situation it doesn't help when os.path functions strip the direc

Re: Behaviour of os.path.join

2020-05-27 Thread BlindAnagram
On 27/05/2020 13:30, Ben Bacarisse wrote: > BlindAnagram writes: > >> The issue that I raised here was whether the behaviour of os.path.join() >> in treating the Windows directory separator '\\' as an absolute path >> should be considered a bug. > > Y

Re: Behaviour of os.path.join

2020-05-27 Thread Ben Bacarisse
BlindAnagram writes: > The issue that I raised here was whether the behaviour of os.path.join() > in treating the Windows directory separator '\\' as an absolute path > should be considered a bug. You think it should be considered to be a relative path? The only meaning

Re: Behaviour of os.path.join

2020-05-27 Thread BlindAnagram
; |>>> import pathlib >>> |>>> import os >>> |>>> pathlib.PureWindowsPath('\\').is_absolute() >>> |False >>> |>>> pathlib.PureWindowsPath(os.sep).is_absolute() >>> |False >>> |>>> pathlib

Re: Behaviour of os.path.join

2020-05-27 Thread Chris Angelico
On Wed, May 27, 2020 at 6:50 PM Barry Scott wrote: > > > > > On 26 May 2020, at 18:01, BlindAnagram wrote: > > > > On 26/05/2020 17:09, Stefan Ram wrote: > >> Mats Wichmann writes: > >>> an absolute path is one that starts with the pathname separator. > >> > >> The Python Library Reference does

Re: Behaviour of os.path.join

2020-05-27 Thread Barry Scott
> On 26 May 2020, at 18:01, BlindAnagram wrote: > > On 26/05/2020 17:09, Stefan Ram wrote: >> Mats Wichmann 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 sepa

Re: Behaviour of os.path.join

2020-05-27 Thread Barry Scott
> On 26 May 2020, at 17:46, MRAB wrote: > > On 2020-05-26 16:48, BlindAnagram wrote: >> On 26/05/2020 16:22, Ben Bacarisse wrote: >>> BlindAnagram writes: I came across an issue that I am wondering whether I should report as an issue. If I have a directory, say: base='C

Re: Behaviour of os.path.join

2020-05-26 Thread Grant Edwards
On 2020-05-26, Dennis Lee Bieber wrote: > I'd also like to point out that the nasty "\\" is not needed. Windows > API understands "/" -- it is only the command line "DOS" shell that > requires back-slash Many, many applications also require that backslashes be used in path arguments (wheth

Re: Behaviour of os.path.join

2020-05-26 Thread DL Neil via Python-list
On 27/05/20 5:23 AM, BlindAnagram wrote: On 26/05/2020 16:59, Mats Wichmann wrote: On 5/26/20 8:56 AM, BlindAnagram wrote: 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:

Re: Behaviour of os.path.join

2020-05-26 Thread MRAB
On 2020-05-26 16:52, Dennis Lee Bieber wrote: On Tue, 26 May 2020 16:22:27 +0100, Ben Bacarisse declaimed the following: I think it is. The picture is messy on Windows (because of the drive letter) but absolute paths are usually taken to be those that start with a path separator. Th

Re: Behaviour of os.path.join

2020-05-26 Thread BlindAnagram
On 26/05/2020 18:51, Mats Wichmann wrote: > On 5/26/20 10:57 AM, BlindAnagram wrote: >> On 26/05/2020 16:59, Mats Wichmann wrote: >>> On 5/26/20 8:56 AM, BlindAnagram wrote: I came across an issue that I am wondering whether I should report as an issue. If I have a directory, say: >

Re: Behaviour of os.path.join

2020-05-26 Thread Mats Wichmann
On 5/26/20 10:57 AM, BlindAnagram wrote: > On 26/05/2020 16:59, Mats Wichmann wrote: >> On 5/26/20 8:56 AM, BlindAnagram wrote: >>> 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.pa

Re: Behaviour of os.path.join

2020-05-26 Thread BlindAnagram
On 26/05/2020 16:59, Mats Wichmann wrote: > On 5/26/20 8:56 AM, BlindAnagram wrote: >> 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, '..\\..\\

Re: Behaviour of os.path.join

2020-05-26 Thread Rhodri James
On 26/05/2020 18:07, BlindAnagram wrote: On 26/05/2020 17:46, MRAB wrote: On 2020-05-26 16:48, BlindAnagram wrote: On 26/05/2020 16:22, Ben Bacarisse wrote: BlindAnagram writes: I came across an issue that I am wondering whether I should report as an issue.  If I have a directory, say:  

Re: Behaviour of os.path.join

2020-05-26 Thread Rhodri James
On 26/05/2020 18:01, BlindAnagram wrote: On 26/05/2020 17:09, Stefan Ram wrote: Mats Wichmann 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

Re: Behaviour of os.path.join

2020-05-26 Thread BlindAnagram
On 26/05/2020 17:46, MRAB wrote: > On 2020-05-26 16:48, BlindAnagram wrote: >> On 26/05/2020 16:22, Ben Bacarisse wrote: >>> BlindAnagram writes: >>> I came across an issue that I am wondering whether I should report as an issue.  If I have a directory, say:   base='C:\\Do

Re: Behaviour of os.path.join

2020-05-26 Thread BlindAnagram
On 26/05/2020 17:09, Stefan Ram wrote: > Mats Wichmann 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).

Re: Behaviour of os.path.join

2020-05-26 Thread BlindAnagram
On 26/05/2020 16:59, Mats Wichmann wrote: > On 5/26/20 8:56 AM, BlindAnagram wrote: >> 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, '..\\..\\

Re: Behaviour of os.path.join

2020-05-26 Thread MRAB
On 2020-05-26 16:48, BlindAnagram wrote: On 26/05/2020 16:22, Ben Bacarisse wrote: BlindAnagram writes: 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, '..\

Re: Behaviour of os.path.join

2020-05-26 Thread Mats Wichmann
On 5/26/20 8:56 AM, BlindAnagram wrote: > 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 th

Re: Behaviour of os.path.join

2020-05-26 Thread BlindAnagram
On 26/05/2020 16:25, Stefan Ram wrote: > BlindAnagram writes: >> The documentation says that an absolute path in the parameter list for >> join will discard all previous parameters but '\\' is not an absoute path! > > The source code for "join" in "ntpath.py" does not seem to > bother to call

Re: Behaviour of os.path.join

2020-05-26 Thread BlindAnagram
On 26/05/2020 16:22, Ben Bacarisse wrote: > BlindAnagram writes: > >> 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', '')

Re: Behaviour of os.path.join

2020-05-26 Thread Ben Bacarisse
BlindAnagram writes: > 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', '') It rather defeats the purpose of os.sep if you inclu

Behaviour of os.path.join

2020-05-26 Thread BlindAnagram
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