Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
225d3c80
Commit
225d3c80
authored
Apr 09, 2008
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#2580: int() docs revision.
parent
014197ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
Doc/library/functions.rst
Doc/library/functions.rst
+14
-12
No files found.
Doc/library/functions.rst
View file @
225d3c80
...
@@ -556,18 +556,20 @@ available. They are listed here in alphabetical order.
...
@@ -556,18 +556,20 @@ available. They are listed here in alphabetical order.
to provide elaborate line editing and history features.
to provide elaborate line editing and history features.
.. function:: int([x[, radix]])
.. function:: int([number | string[, radix]])
Convert a string or number to an integer. If the argument is a string, it
Convert a number or string to an integer. If no arguments are given, return
must contain a possibly signed number of arbitrary size, possibly embedded in
``0``. If a number is given, return ``number.__int__()``. Conversion of
whitespace. The *radix* parameter gives the base for the conversion (which
floating point numbers to integers truncates towards zero. A string must be
is 10 by default) and may be any integer in the range [2, 36], or zero. If
a base-radix integer literal optionally preceded by '+' or '-' (with no space
*radix* is zero, the interpretation is the same as for integer literals. If
in between) and optionally surrounded by whitespace. A base-n literal
*radix* is specified and *x* is not a string, :exc:`TypeError` is raised.
consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') having
Otherwise, the argument may be another integer, a floating point number or
values 10 to 35. The default radix is 10. The allowed values are 0 and 2-36.
any other object that has an :meth:`__int__` method. Conversion of floating
Base-2, -8, and -16 literals can be optionally prefixed with ``0b``/``0B``,
point numbers to integers truncates (towards zero). If no arguments are
``0o``/``0O``, or ``0x``/``0X``, as with integer literals in code. Radix 0
given, returns ``0``.
means to interpret exactly as a code literal, so that the actual radix is 2,
8, 10, or 16, and so that ``int('010', 0)`` is not legal, while
``int('010')`` is, as well as ``int('010', 8)``.
The integer type is described in :ref:`typesnumeric`.
The integer type is described in :ref:`typesnumeric`.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment