Author princemallow
Recipients princemallow
Date 2016-11-04.16:27:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1478276821.6.0.581730112081.issue28611@psf.upfronthosting.co.za>
In-reply-to
Content
I'm not sure if this is a bug or not but I've noticed a behavior that seems incorrect.

The use of raw strings, when used for directory paths ending with a back slash (/) creates a syntax error.

How to reproduce
----------------

Code:

print (r"C:\path\to\a\dir\" + "file.ext")

Result: Syntax Error

Why is this an error, (in my perspective)
-----------------------------------------

One could attempt to be storing the directory information in a variable to write to file that is composed later but would be forced to use a cumbersome normal string having to escape all backslashes.

Example:

outputdir = r"C:\path\to\dir\"
filename = r"file.ext"
writetofile(outputdir + filename)

Argument for why the workaround is not a fix
--------------------------------------------

I believe I read somewhere that python is smart enough to deal with filepaths correctly on linux and windows if you were to switch the slashes. So technically 
outputdir = r"C:/path/to/dir/" 
would work
however this is hard on the workflow since I find it easier to copy and paste paths within windows.

I guess it wouldn't be too unreasonable to do something like:
r"C:\path\to\dir/"
History
Date User Action Args
2016-11-04 16:27:01princemallowsetrecipients: + princemallow
2016-11-04 16:27:01princemallowsetmessageid: <1478276821.6.0.581730112081.issue28611@psf.upfronthosting.co.za>
2016-11-04 16:27:01princemallowlinkissue28611 messages
2016-11-04 16:27:00princemallowcreate