Ryan said:
True, but at least all it takes is a simple System.out.println or log.debug
to see if your SQL is correct.
I have to correct myself. In Python, """ can have escape sequences like
any normal string. Only r" has limited escape sequences:
"When an "r" or "R" prefix is present, a character following a backslash
is included in the string without change, and all backslashes are left
in the string. For example, the string literal r"\n" consists of two
characters: a backslash and a lowercase "n". String quotes can be
escaped with a backslash, but the backslash remains in the string; for
example, r"\"" is a valid string literal consisting of two characters: a
backslash and a double quote; r"\" is not a valid string literal (even a
raw string cannot end in an odd number of backslashes). Specifically, a
raw string cannot end in a single backslash (since the backslash would
escape the following quote character). Note also that a single backslash
followed by a newline is interpreted as those two characters as part of
the string, not as a line continuation."
So r" string can have " in it. Also:
"When an "r" or "R" prefix is used in conjunction with a "u" or "U"
prefix, then the \uXXXX escape sequence is processed while all other
backslashes are left in the string. For example, the string literal
ur"\u0062\n" consists of three Unicode characters: `LATIN SMALL LETTER
B', `REVERSE SOLIDUS', and `LATIN SMALL LETTER N'. Backslashes can be
escaped with a preceding backslash; however, both remain in the string.
As a result, \uXXXX escape sequences are only recognized when there are
an odd number of backslashes. "
"In triple-quoted strings, unescaped newlines and quotes are allowed
(and are retained), except that three unescaped quotes in a row
terminate the string. (A ``quote'' is the character used to open the
string, i.e. either ' or ".)"
All this is a bit confusing compared to how C# handles this:
"A verbatim string literal consists of an @ character followed by a
double-quote character, zero or more characters, and a closing
double-quote character. A simple example is @"hello". In a verbatim
string literal, the characters between the delimiters are interpreted
verbatim, the only exception being a quote-escape-sequence. In
particular, simple escape sequences and hexadecimal and Unicode escape
sequences are not processed in verbatim string literals. A verbatim
string literal may span multiple lines."
This sounds good, except that " has to be doubled. The ideal Java
verbatim string would be something like:
String s = @"can have anything here,
including line feeds, file paths like:
C:\Windows
even tabulators. How to embed " then? Simple, the terminating " must
have @ after it."@;
This way the only string sequence that is now allowed is the closing "@.
Perhaps there could be better terminators, like {"How about this then?"}
or <"And this?">. There are also a couple of characters that are not
normally used: ´Would this be cool?´ `Probably not.`
Harri