Rawest raw string literals

Tim Chase python.list at tim.thechases.com
Sat Apr 22 17:28:22 EDT 2017


On 2017-04-22 23:13, Mikhail V wrote:
> k = r"abc
>       def"
> 
> gives an error:
> 
>     k = r"abc
>             ^
> SyntaxError: EOL while scanning string literal
> 
> So one could define a rule, that a raw string *must*
> be terminated by the sequence quote + newline.
> In theory.

Though one can do

  k = r"""abc
     def
     ghi
     jkl
     mno
     pqrs
     \tuv
     wxyz
     """


which keeps the "\" while allowing multi-line strings.

-tkc





More information about the Python-list mailing list