Re: File names with slashes [was Re: error in os.chdir]

2018-07-05 Thread Gene Heskett
On Thursday 05 July 2018 11:57:18 Mikhail V wrote: > Steven D'Aprano wrote: > > In Explorer and the open-file dialog of most applications, they will > > see paths like this: > > > > directory\file name with spaces > > > > with the extension (.jpg, .pdf, .docx etc) suppressed. So by your > >

File names with slashes [was Re: error in os.chdir]

2018-07-05 Thread Mikhail V
Steven D'Aprano wrote: > In Explorer and the open-file dialog of most applications, they will see > paths like this: > > directory\file name with spaces > > with the extension (.jpg, .pdf, .docx etc) suppressed. So by your > argument, Python needs to accept strings without quotes: > >

Re: File names with slashes [was Re: error in os.chdir]

2018-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2018 00:56:22 +0300, Mikhail V wrote: > for the user it is most important to > *see* and copy-paste the path string exactly as it is displayed > everywhere else on windows. So in Windows, you see: dir directory\file.pdf so in Python, we have to use exactly the same path with

Re: File names with slashes [was Re: error in os.chdir]

2018-07-04 Thread Gregory Ewing
Mikhail V wrote: There is one issue that I can't write \ on the end: r"C:\programs\util\" But since I know it's a path and not a file, I just write without trailing \. Indeed. There's never a need to put a backslash on the end of a path, as long as you always use os.path functions or

File names with slashes [was Re: error in os.chdir]

2018-07-04 Thread Mikhail V
ChrisA wrote: > Mikhail V wrote: >> Yes, and the answer was a week ago: just put "r" before the string. >> r"C:\programs\util" >> >> And it worked till now. So why should I replace backslashes with >> forward slashes? >> There is one issue that I can't write \ on the end: >> r"C:\programs\util\"

Re: File names with slashes [was Re: error in os.chdir]

2018-07-04 Thread Mark Lawrence
On 04/07/18 21:30, Chris Angelico wrote: On Thu, Jul 5, 2018 at 6:25 AM, Mikhail V wrote: Joe Pfeiffer wrote: On Windows a path is e.g.: C:\programs\util\ So what is reasonable about using forward slashes? It happens to me that I need to copy-paste real paths like 100 times a day into

Re: File names with slashes [was Re: error in os.chdir]

2018-07-04 Thread Chris Angelico
On Thu, Jul 5, 2018 at 6:25 AM, Mikhail V wrote: > Joe Pfeiffer wrote: > >>> On Windows a path is e.g.: >>> C:\programs\util\ >>> So what is reasonable about using forward slashes? >>> It happens to me that I need to copy-paste real paths like 100 times >>> a day into scripts - do you propose to

File names with slashes [was Re: error in os.chdir]

2018-07-04 Thread Mikhail V
Joe Pfeiffer wrote: >> On Windows a path is e.g.: >> C:\programs\util\ >> So what is reasonable about using forward slashes? >> It happens to me that I need to copy-paste real paths like 100 times >> a day into scripts - do you propose to convert to forward slashes each time? > That's what

Re: File names with slashes [was Re: error in os.chdir]

2018-07-04 Thread Joe Pfeiffer
Mikhail V writes: > [Steven D'Aprano] > >> (The same applies to Unix/Linux systems too, of course.) But while you're >> using Python to manipulate files, you should use Python rules, and that >> is "always use forward slashes". >> >> Is that reasonable? >> >> Under what circumstances would a

Re: File names with slashes [was Re: error in os.chdir]

2018-07-03 Thread Thomas Jollans
On 2018-07-03 14:06, Mikhail V wrote: > Greg wrote: > >> Mikhail V wrote: >>> s= "\"s\"" -> >>> s= {"s"} >> >> But now you need to find another way to represent set literals. > > > I need to find? That comment was not about (current) Python but > rather how I think string should have

File names with slashes [was Re: error in os.chdir]

2018-07-03 Thread Mikhail V
Greg wrote: > Mikhail V wrote: > > s= "\"s\"" -> > > s= {"s"} > > But now you need to find another way to represent set literals. I need to find? That comment was not about (current) Python but rather how I think string should have been from the beginning. So you already like it and

Re: File names with slashes [was Re: error in os.chdir]

2018-07-03 Thread Gregory Ewing
Mikhail V wrote: s= "\"s\"" -> s= {"s"} But now you need to find another way to represent set literals. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

File names with slashes [was Re: error in os.chdir]

2018-07-02 Thread Mikhail V
[Chris A] > [Mikhail] > > So Imo default syntax should be something like: > > > > S = "A:{x41}B:{x42}" > > > > instead of backslashes and Co. > > So how do you represent brace characters in a string? \{ and \} just kidding :-D I would be ok with {L} and {R} - easy on eye and easy to

Re: File names with slashes [was Re: error in os.chdir]

2018-07-02 Thread MRAB
On 2018-07-02 18:16, Richard Damon wrote: On 7/2/18 9:20 AM, Mikhail V wrote: [Richard Damon] The one major issue with backslashes is that they are a special character in string literals, so you either need to use raw literals a remember the few cases they still act as special characters, or

Re: File names with slashes [was Re: error in os.chdir]

2018-07-02 Thread Richard Damon
On 7/2/18 9:20 AM, Mikhail V wrote: > [Richard Damon] > >> The one major issue with backslashes is that they are a special >> character in string literals, so you either need to use raw literals a >> remember the few cases they still act as special characters, or remember >> to convert them to

Re: File names with slashes [was Re: error in os.chdir]

2018-07-02 Thread Chris Angelico
On Tue, Jul 3, 2018 at 2:20 AM, Mikhail V wrote: > [Richard Damon] > >> The one major issue with backslashes is that they are a special >> character in string literals, so you either need to use raw literals a >> remember the few cases they still act as special characters, or remember >> to

Re: File names with slashes [was Re: error in os.chdir]

2018-07-02 Thread Mikhail V
[Richard Damon] > The one major issue with backslashes is that they are a special > character in string literals, so you either need to use raw literals a > remember the few cases they still act as special characters, or remember > to convert them to double back slashes, at a minimum for all the

Re: File names with slashes [was Re: error in os.chdir]

2018-07-02 Thread Karsten Hilbert
Eryk, thanks for your to-the-point in-depth posts. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list

Re: File names with slashes [was Re: error in os.chdir]

2018-07-01 Thread eryk sun
On Sun, Jul 1, 2018 at 4:30 PM, eryk sun wrote: > On Sun, Jul 1, 2018 at 8:51 AM, Steven D'Aprano > >> spam/eggs [...] >> And how would that file be displayed in the Windows GUI file explorer? > > I suppose if a file system allowed forward slash in names that > Explorer would just display it.

Re: File names with slashes [was Re: error in os.chdir]

2018-07-01 Thread Gregory Ewing
eryk sun wrote: Python 2 raw strings are half-baked. Obviously the "r" actually stand for "rare". -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: File names with slashes [was Re: error in os.chdir]

2018-07-01 Thread eryk sun
On Sun, Jul 1, 2018 at 4:00 PM, Abdur-Rahmaan Janhangeer wrote: > one common scenario is > > C:\Users\ > > where \U is taken as a unicode litteral This one is especially annoying in Python 2, since it makes raw unicode strings useless for common path literals. For example: >>>

Re: File names with slashes [was Re: error in os.chdir]

2018-07-01 Thread eryk sun
On Sun, Jul 1, 2018 at 8:51 AM, Steven D'Aprano wrote: > On Sun, 01 Jul 2018 03:18:23 +, eryk sun wrote: > >> Bear in mind that forward slash is just a name character in NT. > > So, using Python, how could you open, write to, and then read from, a > file with a slash in its name? Say,

Re: File names with slashes [was Re: error in os.chdir]

2018-07-01 Thread Abdur-Rahmaan Janhangeer
one common scenario is C:\Users\ where \U is taken as a unicode litteral Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ > > > -- https://mail.python.org/mailman/listinfo/python-list

Re: File names with slashes [was Re: error in os.chdir]

2018-07-01 Thread Richard Damon
On 7/1/18 6:49 AM, Mikhail V wrote: > [Steven D'Aprano] > >> (The same applies to Unix/Linux systems too, of course.) But while you're >> using Python to manipulate files, you should use Python rules, and that >> is "always use forward slashes". >> >> Is that reasonable? >> >> Under what

File names with slashes [was Re: error in os.chdir]

2018-07-01 Thread Mikhail V
[Steven D'Aprano] > (The same applies to Unix/Linux systems too, of course.) But while you're > using Python to manipulate files, you should use Python rules, and that > is "always use forward slashes". > > Is that reasonable? > > Under what circumstances would a user calling open(pathname) in

File names with slashes [was Re: error in os.chdir]

2018-07-01 Thread Steven D'Aprano
On Sun, 01 Jul 2018 03:18:23 +, eryk sun wrote: > Bear in mind that forward slash is just a name character in NT. So, using Python, how could you open, write to, and then read from, a file with a slash in its name? Say, something like: spam/eggs in your home directory. (Is that