Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c706dbf

Browse files
committed
Issue #10610: Document that int(), float(), and complex() accept numeric literals with the Nd property.
1 parent 3b654be commit c706dbf

1 file changed

Lines changed: 46 additions & 40 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -267,46 +267,46 @@ All numeric types (except complex) support the following operations, sorted by
267267
ascending priority (operations in the same box have the same priority; all
268268
numeric operations have a higher priority than comparison operations):
269269

270-
+---------------------+---------------------------------+-------+--------------------+
271-
| Operation | Result | Notes | Full documentation |
272-
+=====================+=================================+=======+====================+
273-
| ``x + y`` | sum of *x* and *y* | | |
274-
+---------------------+---------------------------------+-------+--------------------+
275-
| ``x - y`` | difference of *x* and *y* | | |
276-
+---------------------+---------------------------------+-------+--------------------+
277-
| ``x * y`` | product of *x* and *y* | | |
278-
+---------------------+---------------------------------+-------+--------------------+
279-
| ``x / y`` | quotient of *x* and *y* | | |
280-
+---------------------+---------------------------------+-------+--------------------+
281-
| ``x // y`` | floored quotient of *x* and | \(1) | |
282-
| | *y* | | |
283-
+---------------------+---------------------------------+-------+--------------------+
284-
| ``x % y`` | remainder of ``x / y`` | \(2) | |
285-
+---------------------+---------------------------------+-------+--------------------+
286-
| ``-x`` | *x* negated | | |
287-
+---------------------+---------------------------------+-------+--------------------+
288-
| ``+x`` | *x* unchanged | | |
289-
+---------------------+---------------------------------+-------+--------------------+
290-
| ``abs(x)`` | absolute value or magnitude of | | :func:`abs` |
291-
| | *x* | | |
292-
+---------------------+---------------------------------+-------+--------------------+
293-
| ``int(x)`` | *x* converted to integer | \(3) | :func:`int` |
294-
+---------------------+---------------------------------+-------+--------------------+
295-
| ``float(x)`` | *x* converted to floating point | \(4) | :func:`float` |
296-
+---------------------+---------------------------------+-------+--------------------+
297-
| ``complex(re, im)`` | a complex number with real part | | :func:`complex` |
298-
| | *re*, imaginary part *im*. | | |
299-
| | *im* defaults to zero. | | |
300-
+---------------------+---------------------------------+-------+--------------------+
301-
| ``c.conjugate()`` | conjugate of the complex number | | |
302-
| | *c* | | |
303-
+---------------------+---------------------------------+-------+--------------------+
304-
| ``divmod(x, y)`` | the pair ``(x // y, x % y)`` | \(2) | :func:`divmod` |
305-
+---------------------+---------------------------------+-------+--------------------+
306-
| ``pow(x, y)`` | *x* to the power *y* | \(5) | :func:`pow` |
307-
+---------------------+---------------------------------+-------+--------------------+
308-
| ``x ** y`` | *x* to the power *y* | \(5) | |
309-
+---------------------+---------------------------------+-------+--------------------+
270+
+---------------------+---------------------------------+---------+--------------------+
271+
| Operation | Result | Notes | Full documentation |
272+
+=====================+=================================+=========+====================+
273+
| ``x + y`` | sum of *x* and *y* | | |
274+
+---------------------+---------------------------------+---------+--------------------+
275+
| ``x - y`` | difference of *x* and *y* | | |
276+
+---------------------+---------------------------------+---------+--------------------+
277+
| ``x * y`` | product of *x* and *y* | | |
278+
+---------------------+---------------------------------+---------+--------------------+
279+
| ``x / y`` | quotient of *x* and *y* | | |
280+
+---------------------+---------------------------------+---------+--------------------+
281+
| ``x // y`` | floored quotient of *x* and | \(1) | |
282+
| | *y* | | |
283+
+---------------------+---------------------------------+---------+--------------------+
284+
| ``x % y`` | remainder of ``x / y`` | \(2) | |
285+
+---------------------+---------------------------------+---------+--------------------+
286+
| ``-x`` | *x* negated | | |
287+
+---------------------+---------------------------------+---------+--------------------+
288+
| ``+x`` | *x* unchanged | | |
289+
+---------------------+---------------------------------+---------+--------------------+
290+
| ``abs(x)`` | absolute value or magnitude of | | :func:`abs` |
291+
| | *x* | | |
292+
+---------------------+---------------------------------+---------+--------------------+
293+
| ``int(x)`` | *x* converted to integer | \(3)\(6)| :func:`int` |
294+
+---------------------+---------------------------------+---------+--------------------+
295+
| ``float(x)`` | *x* converted to floating point | \(4)\(6)| :func:`float` |
296+
+---------------------+---------------------------------+---------+--------------------+
297+
| ``complex(re, im)`` | a complex number with real part | \(6) | :func:`complex` |
298+
| | *re*, imaginary part *im*. | | |
299+
| | *im* defaults to zero. | | |
300+
+---------------------+---------------------------------+---------+--------------------+
301+
| ``c.conjugate()`` | conjugate of the complex number | | |
302+
| | *c* | | |
303+
+---------------------+---------------------------------+---------+--------------------+
304+
| ``divmod(x, y)`` | the pair ``(x // y, x % y)`` | \(2) | :func:`divmod` |
305+
+---------------------+---------------------------------+---------+--------------------+
306+
| ``pow(x, y)`` | *x* to the power *y* | \(5) | :func:`pow` |
307+
+---------------------+---------------------------------+---------+--------------------+
308+
| ``x ** y`` | *x* to the power *y* | \(5) | |
309+
+---------------------+---------------------------------+---------+--------------------+
310310

311311
.. index::
312312
triple: operations on; numeric; types
@@ -345,6 +345,12 @@ Notes:
345345
Python defines ``pow(0, 0)`` and ``0 ** 0`` to be ``1``, as is common for
346346
programming languages.
347347

348+
(6)
349+
The numeric literals accepted include the digits ``0`` to ``9`` or any
350+
Unicode equivalent (code points with the ``Nd`` property).
351+
352+
See http://www.unicode.org/Public/6.0.0/ucd/extracted/DerivedNumericType.txt
353+
for a complete list of code points with the ``Nd`` property.
348354

349355

350356
All :class:`numbers.Real` types (:class:`int` and

0 commit comments

Comments
 (0)