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
> > ar
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:
>
> open
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
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
equivalen
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\"
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 scripts
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 c
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 starte
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 user
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 been
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 want
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
[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 rememb
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 r
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 doub
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 conver
[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
>
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
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.
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
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:
>>> ur'C:\User
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, somethi
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
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 circumstan
On Sun, Jul 1, 2018 at 8:50 AM, Steven D'Aprano
wrote:
> On Sun, 01 Jul 2018 03:18:23 +, eryk sun wrote:
>
>> The Windows API handles this, but not for a path that begins with \\?\.
>
> But what about the *Python* API? The Python open() function, and all the
> high-level os.* and os.path.* fun
[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 Pyt
On 2018-07-01 08:50:22 +, Steven D'Aprano wrote:
> On Sun, 01 Jul 2018 03:18:23 +, eryk sun wrote:
> > On Sun, Jul 1, 2018 at 1:44 AM, Steven D'Aprano
> > wrote:
> >> I guess that if the user is using a path beginning with \\?\ they may
> >> or may not need to use backslashes, but I have n
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 still
On Sun, 01 Jul 2018 03:18:23 +, eryk sun wrote:
> On Sun, Jul 1, 2018 at 1:44 AM, Steven D'Aprano
> wrote:
>> On Sat, 30 Jun 2018 23:36:40 +, eryk sun wrote:
>>
>>> Only use forward slashes for legacy DOS paths passed to Windows API
>>> functions. Do not use forward slashes for paths in c
On Sun, 01 Jul 2018 02:22:41 +, eryk sun wrote:
> I use the native API a lot, so for me registry and file paths are just
> paths. It's only the Windows API that separates the two and only the
> Windows API that allows forward slash as a path separator in file paths.
Not being a Windows user,
On Sun, Jul 1, 2018 at 1:44 AM, Steven D'Aprano
wrote:
> On Sat, 30 Jun 2018 23:36:40 +, eryk sun wrote:
>
>> Only use forward slashes for legacy DOS paths passed to Windows API
>> functions. Do not use forward slashes for paths in command line
>> arguments, \\?\ prefixed paths, or registry pa
On Sun, Jul 1, 2018 at 12:43 PM, eryk sun wrote:
> On Sun, Jul 1, 2018 at 2:28 AM, Chris Angelico wrote:
>> On Sun, Jul 1, 2018 at 12:22 PM, eryk sun wrote:
So what if, internally, that's done by converting them to backslashes?
No Python program needs to care. In fact, there are other
On Sun, Jul 1, 2018 at 2:28 AM, Chris Angelico wrote:
> On Sun, Jul 1, 2018 at 12:22 PM, eryk sun wrote:
>>> So what if, internally, that's done by converting them to backslashes?
>>> No Python program needs to care. In fact, there are other conversions,
>>> too - the underlying file system is mo
On Sun, Jul 1, 2018 at 12:22 PM, eryk sun wrote:
>> So what if, internally, that's done by converting them to backslashes?
>> No Python program needs to care. In fact, there are other conversions,
>> too - the underlying file system is most likely using UTF-16 paths,
>> but your Python program nee
On Sun, Jul 1, 2018 at 1:58 AM, Chris Angelico wrote:
> On Sun, Jul 1, 2018 at 10:20 AM, eryk sun wrote:
>> On Sat, Jun 30, 2018 at 11:42 PM, Chris Angelico wrote:
>>> "Legacy" implies that it's the old standard that is now deprecated,
>>
>> I did not mean to imply that DOS paths are deprecated.
On Sun, Jul 1, 2018 at 10:20 AM, eryk sun wrote:
> On Sat, Jun 30, 2018 at 11:42 PM, Chris Angelico wrote:
>> "Legacy" implies that it's the old standard that is now deprecated,
>
> I did not mean to imply that DOS paths are deprecated. That's not what
> legacy means to me.
Unless you are Humpty
On Sat, 30 Jun 2018 23:36:40 +, eryk sun wrote:
> Only use forward slashes for legacy DOS paths passed to Windows API
> functions. Do not use forward slashes for paths in command line
> arguments, \\?\ prefixed paths, or registry paths.
I don't see why this is relevant, or at least not the "c
On Sat, Jun 30, 2018 at 11:42 PM, Chris Angelico wrote:
> On Sun, Jul 1, 2018 at 9:36 AM, eryk sun wrote:
>> On Sat, Jun 30, 2018 at 11:21 AM, Chris Angelico wrote:
>>> On Sat, Jun 30, 2018 at 9:05 PM, Sharan Basappa
>>> wrote:
0
down vote
favorite
I need to change
On 6/30/2018 7:36 PM, eryk sun wrote:
On Sat, Jun 30, 2018 at 11:21 AM, Chris Angelico wrote:
On Sat, Jun 30, 2018 at 9:05 PM, Sharan Basappa
wrote:
0
down vote
favorite
I need to change directory to my local working directory in windows and then
open a file for processing.
Its just a 3 li
On Sun, Jul 1, 2018 at 9:36 AM, eryk sun wrote:
> On Sat, Jun 30, 2018 at 11:21 AM, Chris Angelico wrote:
>> On Sat, Jun 30, 2018 at 9:05 PM, Sharan Basappa
>> wrote:
>>>
>>> 0
>>> down vote
>>> favorite
>>>
>>> I need to change directory to my local working directory in windows and
>>> then op
On Sat, Jun 30, 2018 at 11:21 AM, Chris Angelico wrote:
> On Sat, Jun 30, 2018 at 9:05 PM, Sharan Basappa
> wrote:
>>
>> 0
>> down vote
>> favorite
>>
>> I need to change directory to my local working directory in windows and then
>> open a file for processing.
>> Its just a 3 lines code, as bel
On 06/30/18 07:34, Sharan Basappa wrote:
sorry. I mean why my code worked in one case but did not in the other one.
This worked - os.chdir('D:\Projects\Initiatives\machine learning\programs')
This did not work - os.chdir('D:\Projects\Initiatives\machine
learning\programs\assertion')
only di
On Sat, Jun 30, 2018 at 07:34:46AM -0700, Sharan Basappa wrote:
> sorry. I mean why my code worked in one case but did not in the other one.
>
> This worked - os.chdir('D:\Projects\Initiatives\machine learning\programs')
>
> This did not work - os.chdir('D:\Projects\Initiatives\machine
> learn
On Saturday, 30 June 2018 18:55:53 UTC+5:30, Karsten Hilbert wrote:
> On Sat, Jun 30, 2018 at 05:46:59AM -0700, Sharan Basappa wrote:
>
> > > >> The quick fix:
> > > >>
> > > >> put an r in front of the directory string: r'...'
> > >
> > > Please don't do that. It's the wrong solution -- all yo
On Sat, Jun 30, 2018 at 05:46:59AM -0700, Sharan Basappa wrote:
> > >> The quick fix:
> > >>
> > >> put an r in front of the directory string: r'...'
> >
> > Please don't do that. It's the wrong solution -- all you are doing is
> > postponing failure. It will *seem* to work, until one day you w
On Saturday, 30 June 2018 18:05:02 UTC+5:30, Steven D'Aprano wrote:
> On Sat, 30 Jun 2018 04:47:44 -0700, Sharan Basappa wrote:
>
> >> The quick fix:
> >>
> >> put an r in front of the directory string: r'...'
> >
> > thanks. That works
>
> Please don't do that. It's the wrong solution -- all y
On Sat, 30 Jun 2018 04:47:44 -0700, Sharan Basappa wrote:
>> The quick fix:
>>
>> put an r in front of the directory string: r'...'
>
> thanks. That works
Please don't do that. It's the wrong solution -- all you are doing is
postponing failure. It will *seem* to work, until one day you will wri
for user input, a replace might be the solution, using / in internal code
Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ
Use forward slashes instead of backslashes for all paths.
>
> os.chdir('D:/Projects/Initiatives/machine learning/programs')
>
> ChrisA
> --
> https://mail.python.or
On Saturday, 30 June 2018 16:51:53 UTC+5:30, Karsten Hilbert wrote:
> On Sat, Jun 30, 2018 at 04:05:22AM -0700, Sharan Basappa wrote:
>
> > I need to change directory to my local working directory in windows and
> > then open a file for processing.
> > Its just a 3 lines code, as below:
> > impo
On Sat, Jun 30, 2018 at 9:05 PM, Sharan Basappa
wrote:
>
> 0
> down vote
> favorite
>
> I need to change directory to my local working directory in windows and then
> open a file for processing.
> Its just a 3 lines code, as below:
> import csv
> import os
> os.chdir('D:\Projects\Initiatives\mach
On Sat, Jun 30, 2018 at 04:05:22AM -0700, Sharan Basappa wrote:
> I need to change directory to my local working directory in windows and then
> open a file for processing.
> Its just a 3 lines code, as below:
> import csv
> import os
> os.chdir('D:\Projects\Initiatives\machine learning\programs\
0
down vote
favorite
I need to change directory to my local working directory in windows and then
open a file for processing.
Its just a 3 lines code, as below:
import csv
import os
os.chdir('D:\Projects\Initiatives\machine learning\programs\assertion')
The error is as follows:
WindowsError: [E
52 matches
Mail list logo