summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-10-30 23:00:52 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-10-30 23:00:52 (GMT)
commitf4d016f38a48e15823021b969aa66cabd0f679a8 (patch)
treeb547fe15f78300b11a0944e89a0dd36f0c9eeaaf
parent8efccfdfd17ce2aaf176f7462cf8086e1282b985 (diff)
downloadcpython-f4d016f38a48e15823021b969aa66cabd0f679a8.zip
cpython-f4d016f38a48e15823021b969aa66cabd0f679a8.tar.gz
cpython-f4d016f38a48e15823021b969aa66cabd0f679a8.tar.bz2
Merged revisions 67060-67061 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r67060 | benjamin.peterson | 2008-10-30 17:39:25 -0500 (Thu, 30 Oct 2008) | 1 line backport bin() documentation ........ r67061 | benjamin.peterson | 2008-10-30 17:44:18 -0500 (Thu, 30 Oct 2008) | 1 line finish backporting binary literals and new octal literals docs ........
-rw-r--r--Doc/library/functions.rst9
-rw-r--r--Doc/library/stdtypes.rst17
-rw-r--r--Doc/reference/lexical_analysis.rst7
3 files changed, 23 insertions, 10 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 487fadf..c135651 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -112,6 +112,15 @@ available. They are listed here in alphabetical order.
.. versionadded:: 2.3
+.. function:: bin(x)
+
+ Convert an integer number to a binary string. The result is a valid Python
+ expression. If *x* is not a Python :class:`int` object, it has to define an
+ :meth:`__index__` method that returns an integer.
+
+ .. versionadded:: 2.6
+
+
.. function:: bool([x])
Convert a value to a Boolean, using the standard truth testing procedure. If
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 737ea97..f5a4e6c 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -246,14 +246,15 @@ Complex numbers have a real and imaginary part, which are each implemented using
pair: octal; literals
Numbers are created by numeric literals or as the result of built-in functions
-and operators. Unadorned integer literals (including hex and octal numbers)
-yield plain integers unless the value they denote is too large to be represented
-as a plain integer, in which case they yield a long integer. Integer literals
-with an ``'L'`` or ``'l'`` suffix yield long integers (``'L'`` is preferred
-because ``1l`` looks too much like eleven!). Numeric literals containing a
-decimal point or an exponent sign yield floating point numbers. Appending
-``'j'`` or ``'J'`` to a numeric literal yields a complex number with a zero real
-part. A complex numeric literal is the sum of a real and an imaginary part.
+and operators. Unadorned integer literals (including binary, hex, and octal
+numbers) yield plain integers unless the value they denote is too large to be
+represented as a plain integer, in which case they yield a long integer.
+Integer literals with an ``'L'`` or ``'l'`` suffix yield long integers (``'L'``
+is preferred because ``1l`` looks too much like eleven!). Numeric literals
+containing a decimal point or an exponent sign yield floating point numbers.
+Appending ``'j'`` or ``'J'`` to a numeric literal yields a complex number with a
+zero real part. A complex numeric literal is the sum of a real and an imaginary
+part.
.. index::
single: arithmetic
diff --git a/Doc/reference/lexical_analysis.rst b/Doc/reference/lexical_analysis.rst
index b548722..f05b91b 100644
--- a/Doc/reference/lexical_analysis.rst
+++ b/Doc/reference/lexical_analysis.rst
@@ -605,6 +605,7 @@ Numeric literals
single: long integer literal
single: floating point literal
single: hexadecimal literal
+ single: binary literal
single: octal literal
single: decimal literal
single: imaginary literal
@@ -629,12 +630,14 @@ definitions:
.. productionlist::
longinteger: `integer` ("l" | "L")
- integer: `decimalinteger` | `octinteger` | `hexinteger`
+ integer: `decimalinteger` | `octinteger` | `hexinteger` | `bininteger`
decimalinteger: `nonzerodigit` `digit`* | "0"
- octinteger: "0" `octdigit`+
+ octinteger: "0" ("o" | "O") `octdigit`+ | "0" `octdigit`+
hexinteger: "0" ("x" | "X") `hexdigit`+
+ bininteger: "0" ("b" | "B") `bindigit`+
nonzerodigit: "1"..."9"
octdigit: "0"..."7"
+ bindigit: "0" | "1"
hexdigit: `digit` | "a"..."f" | "A"..."F"
Although both lower case ``'l'`` and upper case ``'L'`` are allowed as suffix