summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2012-03-04 12:33:51 (GMT)
committerArmin Ronacher <armin.ronacher@active-4.com>2012-03-04 12:33:51 (GMT)
commit50364b4a5c8f02ec05d33928e29a8780d9acf968 (patch)
treeb3266288ca25b3c9512589cf49dfbab2e7de9fe2
parent6ecf77b3f8c981a695d4116b010755676bcc61e2 (diff)
downloadcpython-50364b4a5c8f02ec05d33928e29a8780d9acf968.zip
cpython-50364b4a5c8f02ec05d33928e29a8780d9acf968.tar.gz
cpython-50364b4a5c8f02ec05d33928e29a8780d9acf968.tar.bz2
Basic documentation for PEP 414
-rw-r--r--Doc/reference/lexical_analysis.rst10
1 files changed, 9 insertions, 1 deletions
diff --git a/Doc/reference/lexical_analysis.rst b/Doc/reference/lexical_analysis.rst
index 65f8ffd..c94a47f 100644
--- a/Doc/reference/lexical_analysis.rst
+++ b/Doc/reference/lexical_analysis.rst
@@ -401,7 +401,7 @@ String literals are described by the following lexical definitions:
.. productionlist::
stringliteral: [`stringprefix`](`shortstring` | `longstring`)
- stringprefix: "r" | "R"
+ stringprefix: "r" | "u" | "ur" | "R" | "U" | "UR" | "Ur" | "uR"
shortstring: "'" `shortstringitem`* "'" | '"' `shortstringitem`* '"'
longstring: "'''" `longstringitem`* "'''" | '"""' `longstringitem`* '"""'
shortstringitem: `shortstringchar` | `stringescapeseq`
@@ -441,6 +441,9 @@ instance of the :class:`bytes` type instead of the :class:`str` type. They
may only contain ASCII characters; bytes with a numeric value of 128 or greater
must be expressed with escapes.
+As of Python 3.3 it is possible again to prefix unicode strings with a
+``u`` prefix to simplify maintenance of dual 2.x and 3.x codebases.
+
Both string and bytes literals may optionally be prefixed with a letter ``'r'``
or ``'R'``; such strings are called :dfn:`raw strings` and treat backslashes as
literal characters. As a result, in string literals, ``'\U'`` and ``'\u'``
@@ -450,6 +453,11 @@ escapes in raw strings are not treated specially.
The ``'rb'`` prefix of raw bytes literals has been added as a synonym
of ``'br'``.
+ .. versionadded:: 3.3
+ Support for the unicode legacy literal (``u'value'``) and other
+ versions were reintroduced to simplify the maintenance of dual
+ Python 2.x and 3.x codebases. See :pep:`414` for more information.
+
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 ``"``.)