[Python-checkins] r85010 - python/branches/release27-maint/Doc/reference/lexical_analysis.rst

georg.brandl python-checkins at python.org
Sat Sep 25 15:46:23 CEST 2010


Author: georg.brandl
Date: Sat Sep 25 15:46:23 2010
New Revision: 85010
Log:
#1865: document syntax for bytes literals.
Modified:
 python/branches/release27-maint/Doc/reference/lexical_analysis.rst
Modified: python/branches/release27-maint/Doc/reference/lexical_analysis.rst
==============================================================================
--- python/branches/release27-maint/Doc/reference/lexical_analysis.rst	(original)
+++ python/branches/release27-maint/Doc/reference/lexical_analysis.rst	Sat Sep 25 15:46:23 2010
@@ -426,6 +426,7 @@
 .. 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 @@
 ``'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


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /