msg130720 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2011-03-13 03:10 |
Here is a proposed addition to the tutorial noting the problem with using raw strings for windows paths and how to work around it.
|
msg130727 - (view) |
Author: Eli Bendersky (eli.bendersky) *  |
Date: 2011-03-13 06:49 |
Would it not be better to just recommend Windows users not to put that last backslash in at all? IIUC it's only needed to later append file names to directory names, but that's better achieved with os.path.join
|
msg130739 - (view) |
Author: Graham Wideman (gwideman) |
Date: 2011-03-13 12:36 |
Eli: Excellent and thoughtful point. This would indeed be exactly the place to suggest os.path.join as an alternative.
In addition, there are still occasions where one needs to form a string with trailing backslash. Two examples:
1. When writing the string specifying root directory: r'C:\ '[:-1]
2. Using python to prepare command lines to run other command line programs, where an argument may require a final backslash to explicitly specify a target directory (as opposed to a file).
|
msg130742 - (view) |
Author: Ezio Melotti (ezio.melotti) *  |
Date: 2011-03-13 12:52 |
I would rephrase:
+There is one subtle aspect to raw strings that is of special concern to Windows
+programmers: a raw string may not end in an odd number of ``\`` characters.
to something like:
+There is one subtle aspect to raw strings: a raw string may not end in
+an odd number of ``\`` characters. That is of special concern while
+dealing with Windows paths.
Otherwise it seems that this problem only affects raw strings on Windows.
|
msg130743 - (view) |
Author: Eli Bendersky (eli.bendersky) *  |
Date: 2011-03-13 13:17 |
> Ezio Melotti <ezio.melotti@gmail.com> added the comment:
>
> I would rephrase:
> +There is one subtle aspect to raw strings that is of special concern to
> Windows
> +programmers: a raw string may not end in an odd number of ``\``
> characters.
>
> to something like:
> +There is one subtle aspect to raw strings: a raw string may not end in
> +an odd number of ``\`` characters. That is of special concern while
> +dealing with Windows paths.
>
> Otherwise it seems that this problem only affects raw strings on Windows.
>
I agree, but I'd also say something about os.path.join when mentioning
Windows paths, because the vast majority of problems that require the
trailing backslashes can be solved with it.
|
msg130744 - (view) |
Author: Ezio Melotti (ezio.melotti) *  |
Date: 2011-03-13 14:22 |
That would of course be a good addition too.
|
msg130748 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2011-03-13 15:29 |
Well, the problem with both [:-1] and os.path.join is that they are inappropriate for that section of the tutorial. I considered putting the discussion later in the section so that I could use [:-1] (which hasn't been introduced at that point), but it made the flow even worse than adding the text where I did. I suppose the os.path.join could be put in if the sentence was short and cross referenced the library docs rather than going into a detailed example.
|
msg227698 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2014-09-27 16:38 |
I'm on a quest to clear my 'commit ready' queue. This issue needs to go back to 'needs patch' stage...I'll leave it to someone else to rewrite my original patch based on the feedback, since it is unlikely I will get back to it any time soon. I'll commit it if someone else does the revision and moves it back to commit review, though ;)
|
msg399988 - (view) |
Author: Irit Katriel (iritkatriel) *  |
Date: 2021-08-20 18:10 |
The patch needs to be converted into a github PR, and modified according to the feedback on this issue.
|
|
Date |
User |
Action |
Args |
2022-04-11 14:57:14 | admin | set | github: 55688 |
2021-08-25 15:52:29 | dancinglightning | set | nosy:
+ dancinglightning
pull_requests:
+ pull_request26396 stage: needs patch -> patch review |
2021-08-20 18:10:59 | iritkatriel | set | versions:
+ Python 3.9, Python 3.10, Python 3.11, - Python 2.7, Python 3.4, Python 3.5 nosy:
+ iritkatriel
messages:
+ msg399988
keywords:
+ easy |
2014-09-27 16:38:30 | r.david.murray | set | stage: commit review -> needs patch messages:
+ msg227698 versions:
+ Python 3.5, - Python 3.2, Python 3.3 |
2013-03-14 07:39:57 | ezio.melotti | set | stage: patch review -> commit review |
2012-11-08 10:39:16 | serhiy.storchaka | set | title: Add discussion of trailing slash in raw string to tutorial -> Add discussion of trailing backslash in raw string to tutorial |
2012-11-08 08:31:54 | ezio.melotti | set | type: behavior -> enhancement versions:
+ Python 3.4, - Python 3.1 |
2011-03-13 15:29:05 | r.david.murray | set | nosy:
georg.brandl, facundobatista, QuantumTim, ezio.melotti, v+python, r.david.murray, eli.bendersky, docs@python, gwideman messages:
+ msg130748 |
2011-03-13 14:22:50 | ezio.melotti | set | nosy:
georg.brandl, facundobatista, QuantumTim, ezio.melotti, v+python, r.david.murray, eli.bendersky, docs@python, gwideman messages:
+ msg130744 |
2011-03-13 13:21:28 | SilentGhost | set | files:
- unnamed nosy:
georg.brandl, facundobatista, QuantumTim, ezio.melotti, v+python, r.david.murray, eli.bendersky, docs@python, gwideman |
2011-03-13 13:17:16 | eli.bendersky | set | files:
+ unnamed
messages:
+ msg130743 nosy:
georg.brandl, facundobatista, QuantumTim, ezio.melotti, v+python, r.david.murray, eli.bendersky, docs@python, gwideman |
2011-03-13 12:52:17 | ezio.melotti | set | nosy:
+ ezio.melotti messages:
+ msg130742
|
2011-03-13 12:36:02 | gwideman | set | nosy:
georg.brandl, facundobatista, QuantumTim, v+python, r.david.murray, eli.bendersky, docs@python, gwideman messages:
+ msg130739 |
2011-03-13 06:49:09 | eli.bendersky | set | nosy:
+ eli.bendersky messages:
+ msg130727
|
2011-03-13 03:10:02 | r.david.murray | create | |