Index: Doc/reference/lexical_analysis.rst =================================================================== --- Doc/reference/lexical_analysis.rst (revision 67036) +++ Doc/reference/lexical_analysis.rst (working copy) @@ -606,6 +606,7 @@ single: floating point literal single: hexadecimal literal single: octal literal + single: binary literal single: decimal literal single: imaginary literal single: complex; literal @@ -631,9 +632,11 @@ longinteger: `integer` ("l" | "L") integer: `decimalinteger` | `octinteger` | `hexinteger` decimalinteger: `nonzerodigit` `digit`* | "0" - octinteger: "0" `octdigit`+ + bininteger: "0" ("b" | "B") `bindigit`+ + octinteger: "0" ("o" | "O") `octdigit`+ | "0" `octdigit`+ hexinteger: "0" ("x" | "X") `hexdigit`+ nonzerodigit: "1"..."9" + bindigit: "0" | "1" octdigit: "0"..."7" hexdigit: `digit` | "a"..."f" | "A"..."F" Index: Doc/library/stdtypes.rst =================================================================== --- Doc/library/stdtypes.rst (revision 67036) +++ Doc/library/stdtypes.rst (working copy) @@ -244,9 +244,11 @@ pair: complex number; literals pair: hexadecimal; literals pair: octal; literals + pair: binary; 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) +and operators. Unadorned integer literals (including hexadecimal, octal and +binary 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 Index: Doc/library/functions.rst =================================================================== --- Doc/library/functions.rst (revision 67036) +++ Doc/library/functions.rst (working copy) @@ -112,6 +112,15 @@ .. 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