Patch #744877: Explain filter in terms of list comprehension. Remove

explanation of int in terms of string.atoi. Explain sum in terms of
reduce.
This commit is contained in:
Martin v. Löwis 2003-05-31 08:02:38 +00:00
parent 96ce805725
commit 7472336444
1 changed files with 8 additions and 3 deletions

View File

@ -439,6 +439,11 @@ class C:
is always a list. If \var{function} is \code{None}, the identity is always a list. If \var{function} is \code{None}, the identity
function is assumed, that is, all elements of \var{list} that are false function is assumed, that is, all elements of \var{list} that are false
(zero or empty) are removed. (zero or empty) are removed.
Note that \code{filter(function, list)} equals
\code{[item for item in list if function(item)]} if function is not
\code{None} and \code{[item for item in list if item]} if function is
None.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{float}{x} \begin{funcdesc}{float}{x}
@ -537,9 +542,8 @@ class C:
\begin{funcdesc}{int}{x\optional{, radix}} \begin{funcdesc}{int}{x\optional{, radix}}
Convert a string or number to a plain integer. If the argument is a Convert a string or number to a plain integer. If the argument is a
string, it must contain a possibly signed decimal number string, it must contain a possibly signed decimal number
representable as a Python integer, possibly embedded in whitespace; representable as a Python integer, possibly embedded in whitespace.
this behaves identical to \code{string.atoi(\var{x}\optional{, The \var{radix} parameter gives the base for the
\var{radix}})}. The \var{radix} parameter gives the base for the
conversion and may be any integer in the range [2, 36], or zero. If conversion and may be any integer in the range [2, 36], or zero. If
\var{radix} is zero, the proper radix is guessed based on the \var{radix} is zero, the proper radix is guessed based on the
contents of string; the interpretation is the same as for integer contents of string; the interpretation is the same as for integer
@ -904,6 +908,7 @@ class C:
The \var{sequence}'s items are normally numbers, and are not allowed The \var{sequence}'s items are normally numbers, and are not allowed
to be strings. The fast, correct way to concatenate sequence of to be strings. The fast, correct way to concatenate sequence of
strings is by calling \code{''.join(\var{sequence})}. strings is by calling \code{''.join(\var{sequence})}.
Note that \code{sum(range(n), m)} equals \code{reduce(operator.add, range(n), m)}
\versionadded{2.3} \versionadded{2.3}
\end{funcdesc} \end{funcdesc}