Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(157323)

Side by Side Diff: Doc/library/functions.rst

Issue 16036: simplify int() signature docs
Patch Set: Created 7 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 .. XXX document all delegations to __special__ methods 1 .. XXX document all delegations to __special__ methods
2 .. _built-in-funcs: 2 .. _built-in-funcs:
3 3
4 Built-in Functions 4 Built-in Functions
5 ================== 5 ==================
6 6
7 The Python interpreter has a number of functions and types built into it that 7 The Python interpreter has a number of functions and types built into it that
8 are always available. They are listed here in alphabetical order. 8 are always available. They are listed here in alphabetical order.
9 9
10 =================== ================= ================== ================ == ================== 10 =================== ================= ================== ================ == ==================
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 622
623 >>> s = input('--> ') # doctest: +SKIP 623 >>> s = input('--> ') # doctest: +SKIP
624 --> Monty Python's Flying Circus 624 --> Monty Python's Flying Circus
625 >>> s # doctest: +SKIP 625 >>> s # doctest: +SKIP
626 "Monty Python's Flying Circus" 626 "Monty Python's Flying Circus"
627 627
628 If the :mod:`readline` module was loaded, then :func:`input` will use it 628 If the :mod:`readline` module was loaded, then :func:`input` will use it
629 to provide elaborate line editing and history features. 629 to provide elaborate line editing and history features.
630 630
631 631
632 .. function:: int([number | string[, base]]) 632 .. function:: int(x=0)
633 int(x, base=10)
633 634
634 Convert a number or string to an integer. If no arguments are given, return 635 Convert a number or string *x* to an integer, or return ``0`` if no arguments
635 ``0``. If a number is given, return ``number.__int__()``. Conversion of 636 are given. If *x* is a number, return :meth:`x.__int__() <object.__int__>`.
636 floating point numbers to integers truncates towards zero. A string must be 637 For floating point numbers, this truncates towards zero.
storchaka 2012/09/27 11:06:39 I don't know if it worth to mention specifically s
cjerdonek 2012/09/27 11:47:12 Truncation towards zero seems like useful informat
ezio.melotti 2012/09/27 12:30:20 This was already there. I think the goal is to sa
637 a base-radix integer literal optionally preceded by '+' or '-' (with no space 638
639 If *base* is given, then *x* must be a string. The string must be
storchaka 2012/09/27 09:29:55 Somewhere should be exposed that x must be str, by
640 a base-radix integer literal optionally preceded by ``+`` or ``-`` (with no s pace
638 in between) and optionally surrounded by whitespace. A base-n literal 641 in between) and optionally surrounded by whitespace. A base-n literal
639 consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') having 642 consists of the digits 0 to n-1, with ``a`` to ``z`` (or ``A`` to ``Z``) havi ng
640 values 10 to 35. The default *base* is 10. The allowed values are 0 and 2-36 . 643 values 10 to 35. The default *base* is 10. The allowed values are 0 and 2-36 .
641 Base-2, -8, and -16 literals can be optionally prefixed with ``0b``/``0B``, 644 Base-2, -8, and -16 literals can be optionally prefixed with ``0b``/``0B``,
642 ``0o``/``0O``, or ``0x``/``0X``, as with integer literals in code. Base 0 645 ``0o``/``0O``, or ``0x``/``0X``, as with integer literals in code. Base 0
643 means to interpret exactly as a code literal, so that the actual base is 2, 646 means to interpret exactly as a code literal, so that the actual base is 2,
644 8, 10, or 16, and so that ``int('010', 0)`` is not legal, while 647 8, 10, or 16, and so that ``int('010', 0)`` is not legal, while
645 ``int('010')`` is, as well as ``int('010', 8)``. 648 ``int('010')`` is, as well as ``int('010', 8)``.
646 649
647 The integer type is described in :ref:`typesnumeric`. 650 The integer type is described in :ref:`typesnumeric`.
648 651
649 652
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 1466
1464 .. rubric:: Footnotes 1467 .. rubric:: Footnotes
1465 1468
1466 .. [#] Note that the parser only accepts the Unix-style end of line convention. 1469 .. [#] Note that the parser only accepts the Unix-style end of line convention.
1467 If you are reading the code from a file, make sure to use newline conversion 1470 If you are reading the code from a file, make sure to use newline conversion
1468 mode to convert Windows or Mac-style newlines. 1471 mode to convert Windows or Mac-style newlines.
1469 1472
1470 .. [#] In the current implementation, local variable bindings cannot normally be 1473 .. [#] In the current implementation, local variable bindings cannot normally be
1471 affected this way, but variables retrieved from other scopes (such as modules ) 1474 affected this way, but variables retrieved from other scopes (such as modules )
1472 can be. This may change. 1475 can be. This may change.
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+