Commit c706dbfa authored by Raymond Hettinger's avatar Raymond Hettinger

Issue #10610: Document that int(), float(), and complex() accept numeric...

Issue #10610: Document that int(), float(), and complex() accept numeric literals with the Nd property.
parent 3b654be1
...@@ -267,46 +267,46 @@ All numeric types (except complex) support the following operations, sorted by ...@@ -267,46 +267,46 @@ All numeric types (except complex) support the following operations, sorted by
ascending priority (operations in the same box have the same priority; all ascending priority (operations in the same box have the same priority; all
numeric operations have a higher priority than comparison operations): numeric operations have a higher priority than comparison operations):
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| Operation | Result | Notes | Full documentation | | Operation | Result | Notes | Full documentation |
+=====================+=================================+=======+====================+ +=====================+=================================+=========+====================+
| ``x + y`` | sum of *x* and *y* | | | | ``x + y`` | sum of *x* and *y* | | |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``x - y`` | difference of *x* and *y* | | | | ``x - y`` | difference of *x* and *y* | | |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``x * y`` | product of *x* and *y* | | | | ``x * y`` | product of *x* and *y* | | |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``x / y`` | quotient of *x* and *y* | | | | ``x / y`` | quotient of *x* and *y* | | |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``x // y`` | floored quotient of *x* and | \(1) | | | ``x // y`` | floored quotient of *x* and | \(1) | |
| | *y* | | | | | *y* | | |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``x % y`` | remainder of ``x / y`` | \(2) | | | ``x % y`` | remainder of ``x / y`` | \(2) | |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``-x`` | *x* negated | | | | ``-x`` | *x* negated | | |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``+x`` | *x* unchanged | | | | ``+x`` | *x* unchanged | | |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``abs(x)`` | absolute value or magnitude of | | :func:`abs` | | ``abs(x)`` | absolute value or magnitude of | | :func:`abs` |
| | *x* | | | | | *x* | | |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``int(x)`` | *x* converted to integer | \(3) | :func:`int` | | ``int(x)`` | *x* converted to integer | \(3)\(6)| :func:`int` |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``float(x)`` | *x* converted to floating point | \(4) | :func:`float` | | ``float(x)`` | *x* converted to floating point | \(4)\(6)| :func:`float` |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``complex(re, im)`` | a complex number with real part | | :func:`complex` | | ``complex(re, im)`` | a complex number with real part | \(6) | :func:`complex` |
| | *re*, imaginary part *im*. | | | | | *re*, imaginary part *im*. | | |
| | *im* defaults to zero. | | | | | *im* defaults to zero. | | |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``c.conjugate()`` | conjugate of the complex number | | | | ``c.conjugate()`` | conjugate of the complex number | | |
| | *c* | | | | | *c* | | |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``divmod(x, y)`` | the pair ``(x // y, x % y)`` | \(2) | :func:`divmod` | | ``divmod(x, y)`` | the pair ``(x // y, x % y)`` | \(2) | :func:`divmod` |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``pow(x, y)`` | *x* to the power *y* | \(5) | :func:`pow` | | ``pow(x, y)`` | *x* to the power *y* | \(5) | :func:`pow` |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| ``x ** y`` | *x* to the power *y* | \(5) | | | ``x ** y`` | *x* to the power *y* | \(5) | |
+---------------------+---------------------------------+-------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
.. index:: .. index::
triple: operations on; numeric; types triple: operations on; numeric; types
...@@ -345,6 +345,12 @@ Notes: ...@@ -345,6 +345,12 @@ Notes:
Python defines ``pow(0, 0)`` and ``0 ** 0`` to be ``1``, as is common for Python defines ``pow(0, 0)`` and ``0 ** 0`` to be ``1``, as is common for
programming languages. programming languages.
(6)
The numeric literals accepted include the digits ``0`` to ``9`` or any
Unicode equivalent (code points with the ``Nd`` property).
See http://www.unicode.org/Public/6.0.0/ucd/extracted/DerivedNumericType.txt
for a complete list of code points with the ``Nd`` property.
All :class:`numbers.Real` types (:class:`int` and All :class:`numbers.Real` types (:class:`int` and
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment