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

Skip to content

Commit 7472336

Browse files
committed
Patch #744877: Explain filter in terms of list comprehension. Remove
explanation of int in terms of string.atoi. Explain sum in terms of reduce.
1 parent 96ce805 commit 7472336

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Doc/lib/libfuncs.tex

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@ \section{Built-in Functions \label{built-in-funcs}}
439439
is always a list. If \var{function} is \code{None}, the identity
440440
function is assumed, that is, all elements of \var{list} that are false
441441
(zero or empty) are removed.
442+
443+
Note that \code{filter(function, list)} equals
444+
\code{[item for item in list if function(item)]} if function is not
445+
\code{None} and \code{[item for item in list if item]} if function is
446+
None.
442447
\end{funcdesc}
443448

444449
\begin{funcdesc}{float}{x}
@@ -537,9 +542,8 @@ \section{Built-in Functions \label{built-in-funcs}}
537542
\begin{funcdesc}{int}{x\optional{, radix}}
538543
Convert a string or number to a plain integer. If the argument is a
539544
string, it must contain a possibly signed decimal number
540-
representable as a Python integer, possibly embedded in whitespace;
541-
this behaves identical to \code{string.atoi(\var{x}\optional{,
542-
\var{radix}})}. The \var{radix} parameter gives the base for the
545+
representable as a Python integer, possibly embedded in whitespace.
546+
The \var{radix} parameter gives the base for the
543547
conversion and may be any integer in the range [2, 36], or zero. If
544548
\var{radix} is zero, the proper radix is guessed based on the
545549
contents of string; the interpretation is the same as for integer
@@ -904,6 +908,7 @@ \section{Built-in Functions \label{built-in-funcs}}
904908
The \var{sequence}'s items are normally numbers, and are not allowed
905909
to be strings. The fast, correct way to concatenate sequence of
906910
strings is by calling \code{''.join(\var{sequence})}.
911+
Note that \code{sum(range(n), m)} equals \code{reduce(operator.add, range(n), m)}
907912
\versionadded{2.3}
908913
\end{funcdesc}
909914

0 commit comments

Comments
 (0)