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

Skip to content

Commit 1e862e8

Browse files
committed
Update the description of int() to include the radix parameter;
omission noted on c.l.py by Aahz Maruch. Swapped the order of the descriptions of int() and intern() so that int() comes first (the functions are in alphabetic order).
1 parent ef0b5dd commit 1e862e8

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

Doc/lib/libfuncs.tex

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,22 @@ \section{Built-in Functions \label{built-in-funcs}}
312312
Equivalent to \code{eval(raw_input(\var{prompt}))}.
313313
\end{funcdesc}
314314

315+
\begin{funcdesc}{int}{x\optional{, radix}}
316+
Convert a string or number to a plain integer. If the argument is a
317+
string, it must contain a possibly signed decimal number
318+
representable as a Python integer, possibly embedded in whitespace;
319+
this behaves identical to \code{string.atoi(\var{x}\optional{,
320+
\var{radix}})}. The \var{radix} parameter gives the base for the
321+
conversion and may be any integer in the range $[2, 36]$. If
322+
\var{radix} is specified and \var{x} is not a string,
323+
\exception{TypeError} is raised.
324+
Otherwise, the argument may be a plain or
325+
long integer or a floating point number. Conversion of floating
326+
point numbers to integers is defined by the C semantics; normally
327+
the conversion truncates towards zero.\footnote{This is ugly --- the
328+
language definition should require truncation towards zero.}
329+
\end{funcdesc}
330+
315331
\begin{funcdesc}{intern}{string}
316332
Enter \var{string} in the table of ``interned'' strings and return
317333
the interned string -- which is \var{string} itself or a copy.
@@ -325,18 +341,6 @@ \section{Built-in Functions \label{built-in-funcs}}
325341
garbage collected).
326342
\end{funcdesc}
327343

328-
\begin{funcdesc}{int}{x}
329-
Convert a string or number to a plain integer. If the argument is a
330-
string, it must contain a possibly signed decimal number
331-
representable as a Python integer, possibly embedded in whitespace;
332-
this behaves identical to \code{string.atoi(\var{x})}.
333-
Otherwise, the argument may be a plain or
334-
long integer or a floating point number. Conversion of floating
335-
point numbers to integers is defined by the C semantics; normally
336-
the conversion truncates towards zero.\footnote{This is ugly --- the
337-
language definition should require truncation towards zero.}
338-
\end{funcdesc}
339-
340344
\begin{funcdesc}{isinstance}{object, class}
341345
Return true if the \var{object} argument is an instance of the
342346
\var{class} argument, or of a (direct or indirect) subclass thereof.

0 commit comments

Comments
 (0)