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
not (necessarily) offer solutions which are Windows-specific - by definition. Referring to the final conclusion: a solution already exists (again, please refer to docs/link in previous contribution, and repeated 'here' by @Beverley). She provides evidence for macOS, here is same from L

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
e') creates a directory. > open('C:\\Documents\\finance', 'w') creates a file. > > The difference is in the operation, not in the name. > > 'C:\\Documents\\finance' is a pathname, which can refer to either a > directory or a file. > '

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
oks more like a partial pathname, not a complete one. I can't think of any reason for ending pathnames with (back)slashes. Just use os.path.join(directory, filename) when you need to refer to a file in the directory. I would be surprised if issues such as these were not, at least in signi

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', 

Re: Behaviour of os.path.join

2020-05-27 Thread Beverly Pope
ng an empty string as the last part of the path. The following is on macOS (I don’t have a MS Windows machine): >>> import os.path >>> os.path.join('/Users/myID/a', 'b','c') '/Users/myID/a/b/c' >>> os.path.join('/Users/myID/a&

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
.PureWindowsPath('/').is_absolute() >>> |False >> >> Thanks, that seems to suggest that there is an issue and that I should >> hence submit this as an issue. > > Can you post the a link to the issue please? The issue that I raised here was whether the beha

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
e. If I have a directory, say: >>>> >>>> base='C:\\Documents' >>>> >>>> and I use os.path.join() as follows: >>>> >>>> join(base, '..\\..\\', 'build', '') >>> It rathe

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()

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
gt;> 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 Mats Wichmann
> base='C:\\Documents' >>> >>> and I use os.path.join() as follows: >>> >>> join(base, '..\\..\\', 'build', '') >>> >>> I obtain as expected from the documentation: >>> >>> 'C:\\

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

Re: Behaviour of os.path.join

2020-05-26 Thread Rhodri James
:   base='C:\\Documents' and I use os.path.join() as follows:   join(base, '..\\..\\', 'build', '') It rather defeats the purpose of os.sep if you include it in a part of the path.  What you mean is better expressed as   join(base, '..', '..

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
gt;> issue.  If I have a directory, say: >>>> >>>>   base='C:\\Documents' >>>> >>>> and I use os.path.join() as follows: >>>> >>>>   join(base, '..\\..\\', 'build', '') >>> >&g

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

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:

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, '..\\..\\',

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

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'

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:

Re: Struggling with os.path.join and fileinput (was 'Path, strings, and lines'

2015-06-15 Thread MRAB
e filename() and filelineno() function calls with >> the fileinput module. > > By 'qualify', do you mean something like > l.append(fileinput.filename())? > >> >> > FileNotFoundError: [Errno 2] No such file or directory: 'THE LAND OF LOST TOYS~&

Re: Struggling with os.path.join and fileinput (was 'Path, strings, and lines'

2015-06-15 Thread Ian Kelly
On Mon, Jun 15, 2015 at 8:00 PM, Malik Rumi wrote: > I have struggled with this for several hours and not made much progress. I > was not sure if your 'names' variable was supposed to be the same as > 'filenames'. Also, it should be 'os.path.join', not os.

Struggling with os.path.join and fileinput (was 'Path, strings, and lines'

2015-06-15 Thread Malik Rumi
l.append(filename(), filelineno(), line) > >> > >> Although it's not the problem at hand, I think you'll find that you > >> need to qualify the filename() and filelineno() function calls with > >> the fileinput module. > > > >

Re: [Python-ideas] os.path.join

2013-11-04 Thread Serhiy Storchaka
04.11.13 20:01, Mark Lawrence написав(ла): On 04/11/2013 17:34, Ethan Furman wrote: On 11/04/2013 09:29 AM, random...@fastmail.us wrote: I did, incidentally, notice a bug in macpath's *split* function; macpath.split(':foo::bar') should return (':foo::','bar') rather than (':foo:','bar'). Ope

Re: [Python-ideas] os.path.join

2013-11-04 Thread Mark Lawrence
On 04/11/2013 17:34, Ethan Furman wrote: On 11/04/2013 09:29 AM, random...@fastmail.us wrote: I did, incidentally, notice a bug in macpath's *split* function; macpath.split(':foo::bar') should return (':foo::','bar') rather than (':foo:','bar'). Open a bug report. :) http://bugs.python.org

Re: [Python-ideas] os.path.join

2013-11-04 Thread Ethan Furman
On 11/04/2013 09:29 AM, random...@fastmail.us wrote: I did, incidentally, notice a bug in macpath's *split* function; macpath.split(':foo::bar') should return (':foo::','bar') rather than (':foo:','bar'). Open a bug report. :) http://bugs.python.org -- ~Ethan~ -- https://mail.python.org/mai

Re: [Python-ideas] os.path.join

2013-11-04 Thread rusi
On Monday, November 4, 2013 9:47:18 PM UTC+5:30, Chris Angelico wrote: > Blargh, wrong list. It should have been private anyway. Kindly take no > notice of the man behind the 3AM clock... > > > ChrisA Ive got a little list Ive got a little list For Australians of all kinds Ive got a little list

Re: [Python-ideas] os.path.join

2013-11-04 Thread random832
On Mon, Nov 4, 2013, at 11:07, Chris Angelico wrote: > Then os.path.join is probably the wrong tool for the job. Do you want > to collapse "/foo/bar" + "../quux" into "/foo/quux"? That rewrites the > first. If not, don't use a function that does tha

Re: [Python-ideas] os.path.join

2013-11-04 Thread Ethan Furman
first. Then os.path.join is probably the wrong tool for the job. Do you want to collapse "/foo/bar" + "../quux" into "/foo/quux"? That rewrites the first. If not, don't use a function that does that. Try simple string concatenation instead. Wrong mailing list. ;

Re: [Python-ideas] os.path.join

2013-11-04 Thread Chris Angelico
adays. In there if I >> want to join two paths, no matter if 2nd starts with slash or not, I >> don't really expect the 2nd to rewrite the first. > > Then os.path.join is probably the wrong tool for the job. Do you want > to collapse "/foo/bar" + "../quux&qu

Re: [Python-ideas] os.path.join

2013-11-04 Thread Chris Angelico
On Tue, Nov 5, 2013 at 2:29 AM, anatoly techtonik wrote: > Right. But I am working more with URL paths nowadays. In there if I > want to join two paths, no matter if 2nd starts with slash or not, I > don't really expect the 2nd to rewrite the first. Then os.path.join is probably

Re: [os.path.join(r'E:\Python', name) for name in []] returns []

2013-01-29 Thread Chris Angelico
On Wed, Jan 30, 2013 at 12:56 PM, iMath wrote: > 在 2013年1月29日星期二UTC+8下午9时33分26秒,Steven D'Aprano写道: >> iMath wrote: > why [os.path.join(r'E:\Python', name) for name in []] returns >> [] ? Because you are iterating over an empty list, []. That list >> com

Re: [os.path.join(r'E:\Python', name) for name in []] returns []

2013-01-29 Thread iMath
在 2013年1月29日星期二UTC+8下午9时33分26秒,Steven D'Aprano写道: > iMath wrote: > why [os.path.join(r'E:\Python', name) for name in []] returns > [] ? Because you are iterating over an empty list, []. That list > comprehension is the equivalent of: result = [] for name in []: > r

Re: [os.path.join(r'E:\Python', name) for name in []] returns []

2013-01-29 Thread Dave Angel
On 01/29/2013 08:21 AM, iMath wrote: why [os.path.join(r'E:\Python', name) for name in []] returns [] ? please explain it in detail ! [ os.path.join(r'E:\Python', name) for name in [] ] It'd be nice if you would explain what part of it bothers you. Do you know wha

Re: [os.path.join(r'E:\Python', name) for name in []] returns []

2013-01-29 Thread Steven D'Aprano
iMath wrote: > why [os.path.join(r'E:\Python', name) for name in []] returns [] ? Because you are iterating over an empty list, []. That list comprehension is the equivalent of: result = [] for name in []: result.append( os.path.join(r'E:\Python', name) ) Since yo

Re: [os.path.join(r'E:\Python', name) for name in []] returns []

2013-01-29 Thread Jean-Michel Pichavant
- Original Message - > why [os.path.join(r'E:\Python', name) for name in []] returns [] ? > please explain it in detail ! > -- > http://mail.python.org/mailman/listinfo/python-list > You're mapping an empty list. "for name in []" JM -- IMPORT

Re: [os.path.join(r'E:\Python', name) for name in []] returns []

2013-01-29 Thread Chris Angelico
On Wed, Jan 30, 2013 at 12:21 AM, iMath wrote: > why [os.path.join(r'E:\Python', name) for name in []] returns [] ? > please explain it in detail ! That's a list comprehension. If you're familiar with functional programming, it's like a map operation. Since the

[os.path.join(r'E:\Python', name) for name in []] returns []

2013-01-29 Thread iMath
why [os.path.join(r'E:\Python', name) for name in []] returns [] ? please explain it in detail ! -- http://mail.python.org/mailman/listinfo/python-list

Re: A question on os.path.join in POSIX systems

2012-06-22 Thread Dieter Maurer
Kushal Das writes: > There is a comment on posixpath.join saying "Ignore the previous parts > if a part is absolute." It means: "join(something, abspath) == abspath" whenever "abspath" is an absolute path. > Is this defined in the POSIX spec ? If yes, then can someone please > point me to a li

A question on os.path.join in POSIX systems

2012-06-22 Thread Kushal Das
Hi all, There is a comment on posixpath.join saying "Ignore the previous parts if a part is absolute." Is this defined in the POSIX spec ? If yes, then can someone please point me to a link where I can read about it ? Kushal -- http://fedoraproject.org http://kushaldas.in -- http://mail.python

Re: os.path.join doubt

2011-02-03 Thread Westley Martínez
hes. > > > > > > > > > -- > > > Steven > > > > Paths that mix /s and \s are NOT valid on Windows. In one of the > > setup.py scripts I wrote I had to write a function to collect the > > paths of data files for installation. On Windows it didn&

Re: os.path.join doubt

2011-02-03 Thread Thomas L. Shinnick
slashes. -- Steven Paths that mix /s and \s are NOT valid on Windows. In one of the setup.py scripts I wrote I had to write a function to collect the paths of data files for installation. On Windows it didn't work and it was driving me crazy. It wasn't until I realized os.path.join

Re: os.path.join doubt

2011-02-03 Thread Westley Martínez
path.replace('/', '\\') > > before displaying them to the user. Likewise if you have to pass the > paths to some application that doesn't understand slashes. > > > -- > Steven Paths that mix /s and \s are NOT valid on Windows. In one of the setup

Re: os.path.join doubt

2011-02-03 Thread Steven D'Aprano
On Thu, 03 Feb 2011 07:58:55 -0800, Ethan Furman wrote: > Steven D'Aprano wrote: >> BTW, Windows accepts / as well as \ as a path separator. You will have >> far fewer headaches if you use that. > > Just because Windows accepts / doesn't make it a good idea... No. Windows accepting slashes as th

Re: os.path.join doubt

2011-02-03 Thread Ethan Furman
Steven D'Aprano wrote: BTW, Windows accepts / as well as \ as a path separator. You will have far fewer headaches if you use that. Just because Windows accepts / doesn't make it a good idea... Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32 Type "help",

Re: os.path.join doubt

2011-02-03 Thread Westley Martínez
'C:\\Users\\me\\Documents\\..\\Pictures\\images\\my.jpg' is a valid path. .. means parent, not 'go back a directory'. But you should really be trying this: p1 = os.environ['HOMEPATH'] p2 = os.path.join(p1, 'Pictures', 'images', 'my.jpg

Re: os.path.join doubt

2011-02-03 Thread Nobody
rectories should be taken from command-line parameters, registry entries, configuration files, environment variables etc, not embedded into the program. Paths relative to those directories should be constructed with os.path.join(). -- http://mail.python.org/mailman/listinfo/python-list

Re: os.path.join doubt

2011-02-02 Thread Steven D'Aprano
On Wed, 02 Feb 2011 20:46:12 -0800, harryos wrote: > In windows ,I tried this > > p1 = "C:\Users\me\Documents" > p2 = "..\Pictures\images\my.jpg" > > print os.path.join(p1,p2) > This gives > 'C:\\Users\\me\\Documents\\..\\Pictures\\images\\my.

Re: os.path.join doubt

2011-02-02 Thread Chris Rebert
On Wed, Feb 2, 2011 at 8:46 PM, harryos wrote: > In windows ,I tried this > > p1 = "C:\Users\me\Documents" > p2 = "..\Pictures\images\my.jpg" > > print os.path.join(p1,p2) > This gives > 'C:\\Users\\me\\Documents\\..\\Pictures\\images\\my.jpg'

os.path.join doubt

2011-02-02 Thread harryos
In windows ,I tried this p1 = "C:\Users\me\Documents" p2 = "..\Pictures\images\my.jpg" print os.path.join(p1,p2) This gives 'C:\\Users\\me\\Documents\\..\\Pictures\\images\\my.jpg' I expected I would get 'C:\\Users\\me\\Pictures\\images\\my.jpg' I though

Re: os.path.join

2009-10-19 Thread Ethan Furman
ath='z:\\orders'): destination = os.path.join([restore_path, job_num]) print os.path.join([save_path, job_num]) As the astute reader will doubt notice, job_num should be a string. As I was not an astute typer during development, I just put in an integer: -->uncompress_job(18273) [

os.path.join

2009-10-19 Thread Ethan Furman
s'): destination = os.path.join([restore_path, job_num]) print os.path.join([save_path, job_num]) As the astute reader will doubt notice, job_num should be a string. As I was not an astute typer during development, I just put in an integer: -->uncompress_job(18273) ['z:\\oldjobs'

Re: open(os.path.join(os.path.dirname(__file__), '../www/bin/picture.png'), 'rb')

2009-05-16 Thread gert
On May 16, 3:40 pm, gert wrote: > On May 16, 3:16 pm, "Diez B. Roggisch" wrote: > > > gert schrieb: > > > > open(os.path.join(os.path.dirname(__file__),'../www/bin/picture.png'), > > > 'rb') > > > how do you do this on

Re: open(os.path.join(os.path.dirname(__file__), '../www/bin/picture.png'), 'rb')

2009-05-16 Thread gert
On May 16, 3:16 pm, "Diez B. Roggisch" wrote: > gert schrieb: > > > open(os.path.join(os.path.dirname(__file__),'../www/bin/picture.png'), > > 'rb') > > how do you do this on windows (py3) so it still works on linux ? > > os.path.join(&q

Re: open(os.path.join(os.path.dirname(__file__), '../www/bin/picture.png'), 'rb')

2009-05-16 Thread MRAB
Diez B. Roggisch wrote: gert schrieb: open(os.path.join(os.path.dirname(__file__),'../www/bin/picture.png'), 'rb') how do you do this on windows (py3) so it still works on linux ? os.path.join("..", "www", "bin", "picture.png"

Re: open(os.path.join(os.path.dirname(__file__), '../www/bin/picture.png'), 'rb')

2009-05-16 Thread Diez B. Roggisch
gert schrieb: open(os.path.join(os.path.dirname(__file__),'../www/bin/picture.png'), 'rb') how do you do this on windows (py3) so it still works on linux ? os.path.join("..", "www", "bin", "picture.png") Or use os.sep. Diez -- http://mail.python.org/mailman/listinfo/python-list

open(os.path.join(os.path.dirname(__file__), '../www/bin/picture.png'), 'rb')

2009-05-16 Thread gert
open(os.path.join(os.path.dirname(__file__),'../www/bin/picture.png'), 'rb') how do you do this on windows (py3) so it still works on linux ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested os.path.join()'s

2008-05-05 Thread Scott David Daniels
Paul Scott wrote: ... example: if os.path.exists(os.path.join(basedir,picdir)) == True : blah blah Question is, is there a better way of doing this? The above *works* but it looks kinda hackish... You've had the joining addressed elsewhere, but note that: if os.path.e

Re: Nested os.path.join()'s

2008-05-05 Thread Grant Edwards
On 2008-05-05, Paul Scott <[EMAIL PROTECTED]> wrote: > Today, I needed to concatenate a bunch of directory paths and files > together based on user input to create file paths. I achieved this > through nested os.path.join()'s which I am unsure if this is a good > thing or n

Re: Nested os.path.join()'s

2008-05-05 Thread Paul Scott
On Mon, 2008-05-05 at 10:34 -0400, Jean-Paul Calderone wrote: > How about not nesting the calls? > > >>> from os.path import join > >>> join(join('x', 'y'), 'z') == join('x', 'y', 'z') > True > >>> > Great! Thanks. Didn't realise that you could do that... :) --Paul All Email o

Re: Nested os.path.join()'s

2008-05-05 Thread Jean-Paul Calderone
On Mon, 05 May 2008 16:28:33 +0200, Paul Scott <[EMAIL PROTECTED]> wrote: On Mon, 2008-05-05 at 16:21 +0200, Paul Scott wrote: example: if os.path.exists(os.path.join(basedir,picdir)) == True : blah blah Sorry, pasted the wrong example... Better example: pics = glo

Re: Nested os.path.join()'s

2008-05-05 Thread Paul Scott
On Mon, 2008-05-05 at 16:21 +0200, Paul Scott wrote: > example: > > if os.path.exists(os.path.join(basedir,picdir)) == True : > blah blah > Sorry, pasted the wrong example... Better example: pics = glob.glob(os.path.join(os.path.join(basedir,picdir),'*'))

Nested os.path.join()'s

2008-05-05 Thread Paul Scott
Today, I needed to concatenate a bunch of directory paths and files together based on user input to create file paths. I achieved this through nested os.path.join()'s which I am unsure if this is a good thing or not. example: if os.path.exists(os.path.join(basedir,picdir)) == True :

Re: os.path.join

2007-05-03 Thread Tim Roberts
Elliot Peele <[EMAIL PROTECTED]> wrote: >On Tue, 2007-05-01 at 19:27 -0700, 7stud wrote: >> On May 1, 7:36 pm, Elliot Peele <[EMAIL PROTECTED]> wrote: >> > Why does os.path.join('/foo', '/bar') return '/bar' rather than >> > &

Re: os.path.join

2007-05-02 Thread half . italian
On May 2, 12:36 am, Ant <[EMAIL PROTECTED]> wrote: > On May 2, 8:03 am, [EMAIL PROTECTED] wrote: > > > On May 1, 11:10 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > ... > > > I think it's a bug, but because it should raise TypeError instea

  1   2   >