[Python-Dev] this python string literals documentation couldn't explain me: single quote presence inside double quoted string and viceversa. Can Anyone explain me?
Alok Nayak
aloknayak29 at gmail.com
Wed May 8 15:09:52 CEST 2013
Thanks for you answer sir,
I was thinking its regular expressions(automata) not BNF grammer. Aint I
right ?
And I thought even if it is for human reading, if we write literal grammer
( regular expression, in my view) using documentation, we would end up with
python not allowing strings like"python's rule" and ' python"the master" '
Here I changed the defination of string literal for explaining my thinking,
inserted short-singlequoted-stringitem, short-sq-tstringchar,
short-doublequoted-stringitem and short-dq-stringchar . I think we should
use this in documentation
stringliteral ::= [stringprefix](shortstring | longstring)
stringprefix ::= "r" | "u" | "ur" | "R" | "U" | "UR" | "Ur" | "uR"
| "b" | "B" | "br" | "Br" | "bR" | "BR"
shortstring ::= "'" short-singlequoted-stringitem* "'" | '"'
short-doublequoted-stringitem* '"'
longstring ::= "'''" longstringitem* "'''"
| '"""' longstringitem* '"""'
short-singlequoted-stringitem ::= short-sq-stringchar | escapeseq
short-doublequoted-stringitem ::= short-dq-stringchar | escapeseq
longstringitem ::= longstringchar | escapeseq
short-sq-tstringchar ::= <any source character except "\" or newline or
single-quote>
short-dq-stringchar ::= <any source character except "\" or newline or
double-quote>
longstringchar ::= <any source character except "\">
escapeseq ::= "\" <any ASCII character>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130508/46b1c333/attachment.html>
More information about the Python-Dev
mailing list