summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-09-25 13:46:23 (GMT)
committerGeorg Brandl <georg@python.org>2010-09-25 13:46:23 (GMT)
commit7db964d5aaf6a5a17e90c5d4da393476ae53c363 (patch)
tree5571254c3a7b1e9f03aa33f5e7fc080992851eb5
parenta0b6a49583064b1255cc2f12ad4775f1151c96ab (diff)
downloadcpython-7db964d5aaf6a5a17e90c5d4da393476ae53c363.zip
cpython-7db964d5aaf6a5a17e90c5d4da393476ae53c363.tar.gz
cpython-7db964d5aaf6a5a17e90c5d4da393476ae53c363.tar.bz2
#1865: document syntax for bytes literals.
-rw-r--r--Doc/reference/lexical_analysis.rst7
1 files changed, 5 insertions, 2 deletions
diff --git a/Doc/reference/lexical_analysis.rst b/Doc/reference/lexical_analysis.rst
index d4c7990..d716139 100644
--- a/Doc/reference/lexical_analysis.rst
+++ b/Doc/reference/lexical_analysis.rst
@@ -426,6 +426,7 @@ String literals are described by the following lexical definitions:
.. productionlist::
stringliteral: [`stringprefix`](`shortstring` | `longstring`)
stringprefix: "r" | "u" | "ur" | "R" | "U" | "UR" | "Ur" | "uR"
+ : | "b" | "B" | "br" | "Br" | "bR" | "BR"
shortstring: "'" `shortstringitem`* "'" | '"' `shortstringitem`* '"'
longstring: "'''" `longstringitem`* "'''"
: | '"""' `longstringitem`* '"""'
@@ -458,8 +459,10 @@ different rules for interpreting backslash escape sequences. A prefix of
``'u'`` or ``'U'`` makes the string a Unicode string. Unicode strings use the
Unicode character set as defined by the Unicode Consortium and ISO 10646. Some
additional escape sequences, described below, are available in Unicode strings.
-The two prefix characters may be combined; in this case, ``'u'`` must appear
-before ``'r'``.
+A prefix of ``'b'`` or ``'B'`` is ignored in Python 2; it indicates that the
+literal should become a bytes literal in Python 3 (e.g. when code is
+automatically converted with 2to3). A ``'u'`` or ``'b'`` prefix may be followed
+by an ``'r'`` prefix.
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