diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -629,11 +629,15 @@ to provide elaborate line editing and history features. -.. function:: int([number | string[, base]]) +.. function:: int(x=0) + int(x, base=10) - Convert a number or string to an integer. If no arguments are given, return - ``0``. If a number is given, return ``number.__int__()``. Conversion of - floating point numbers to integers truncates towards zero. A string must be + Convert a number or string *x* to an integer. If no arguments are given, + return ``0``. If *x* is a number, return ``x.__int__()``. Otherwise, + convert *x* to an integer using base *base*. + + Conversion of floating point numbers to integers truncates towards zero. If + *base* is given, then *x* must be a string. The string must be a base-radix integer literal optionally preceded by '+' or '-' (with no space in between) and optionally surrounded by whitespace. A base-n literal consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') having