New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add discussion of trailing backslash in raw string to tutorial #55688
Comments
Here is a proposed addition to the tutorial noting the problem with using raw strings for windows paths and how to work around it. |
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 |
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:
|
I would rephrase: to something like: 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 |
That would of course be a good addition too. |
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. |
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 ;) |
The patch needs to be converted into a github PR, and modified according to the feedback on this issue. |
Co-authored-by: hauntsaninja <hauntsaninja@gmail.com>
…thonGH-94768) (cherry picked from commit b95b1b3) Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com> Co-authored-by: hauntsaninja <hauntsaninja@gmail.com>
…thonGH-94768) (cherry picked from commit b95b1b3) Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com> Co-authored-by: hauntsaninja <hauntsaninja@gmail.com>
bitdancer commentedMar 13, 2011
•
edited by bedevere-bot
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: