Kaydet (Commit) 2095b969 authored tarafından Fred Drake's avatar Fred Drake

reduce(): Clarified what is returned in the case of a sequence 1 item long and

initial/default value.
üst 1f4fed68
......@@ -717,12 +717,12 @@ def my_import(name):
\begin{funcdesc}{reduce}{function, sequence\optional{, initializer}}
Apply \var{function} of two arguments cumulatively to the items of
\var{sequence}, from left to right, so as to reduce the sequence to
a single value. For example,
\code{reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])} calculates
\code{((((1+2)+3)+4)+5)}.
If the optional \var{initializer} is present, it is placed before
the items of the sequence in the calculation, and serves as a
default when the sequence is empty.
a single value. For example, \code{reduce(lambda x, y: x+y, [1, 2,
3, 4, 5])} calculates \code{((((1+2)+3)+4)+5)}. If the optional
\var{initializer} is present, it is placed before the items of the
sequence in the calculation, and serves as a default when the
sequence is empty. If \var{initializer} is not given and
\var{sequence} contains only one item, the first item is returned.
\end{funcdesc}
\begin{funcdesc}{reload}{module}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment