[Python-ideas] raw strings

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Oct 2 02:54:32 CEST 2007

Clark Maurer wrote:
> I just don’t understand the rationale for the current implementation.  
>  I thought the intention of raw strings was to allow for backslashes in 
> the string.

That's not *exactly* true. The intention is to allow
backslashes that are *being used to escape something*,
but are to be interpreted by whatever is using the
string, not by Python itself. The original use case
was regular expressions, I believe.

In that case, there is no need to be able to put a
backslash at the end of a string.

Your suggestion of doubling quotes would actually
interfere with this use case, because currently you
can write


and it will be correctly interpreted as a regular
expression with an escaped quote in it. Under your
scheme, it would have to be written


and then it would no longer be WYSIWYG.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | Carpe post meridiem!          	  |
Christchurch, New Zealand	   | (I'm not a morning person.)          |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+

More information about the Python-ideas mailing list