On 8/9/2019 4:08 PM, MRAB wrote:
On
2019-08-09 23:56, Steven D'Aprano wrote:
I'm not trying to be confrontational, I'm
trying to understand your
use-case(s) and see if it would be broken by the planned change
to
string escapes.
On Fri, Aug 09, 2019 at 03:18:29PM -0700, Glenn Linderman wrote:
On 8/9/2019 2:53 PM, Steven D'Aprano
wrote:
>On Fri, Aug 09, 2019 at 01:12:59PM -0700, Glenn Linderman
wrote:
>
>>The reason I never use raw strings is in the
documentation, it is
>>because \ still has a special meaning, and the first
several times I
>>felt the need for raw strings, it was for directory
names that wanted to
>>end with \ and couldn't.
>Can you elaborate? I find it unlikely that I would ever
want a docstring
I didn't mention docstring. I just wanted a string with a
path name ending in \.
You said you never used raw strings in the documentation. I read
that as
doc strings. What sort of documentation are you writing that
isn't a doc
string but is inside your .py files where the difference between
raw and
regular strings is meaningful?
Windows users are used to seeing
backslashes in paths, I don't care to be the one to explain
why my program uses / and all the rest use \.
If you don't use raw strings for paths, you get to explain why
your
program uses \\ and all the rest use \ *wink*
If they're Windows end users, they won't be reading your source
code and
will never know how you represent hard-coded paths in the source
code.
If they're Windows developers, they ought to be aware that the
Windows
file system API allows / anywhere you can use \ and it is the
common convention in Python to use forward slashes.
I'm also curious why the string needs to *end* with a backslash.
Both of
these are the same path:
C:\foo\bar\baz\
C:\foo\bar\baz
The only time it's required is for the root directory of a drive:
C:\
That's not the only time it's required, but it is a case that is far
harder to specify in other ways. It's required any time you want
to say + filename without writing + "\\" + filename, or
os.path.join( 'C:\\", filename )