diff options
author | Guido van Rossum <guido@python.org> | 2006-08-26 20:49:04 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2006-08-26 20:49:04 (GMT) |
commit | 0919a1a07b061ef9a8a94cc1d92c1895b00967cb (patch) | |
tree | 812681b0b579aa36b1117b192c016b7f90ada6b0 /Doc/howto/doanddont.tex | |
parent | 6a2a2a08329567ea41f4f073cb43e487f83872c7 (diff) | |
download | cpython-0919a1a07b061ef9a8a94cc1d92c1895b00967cb.zip cpython-0919a1a07b061ef9a8a94cc1d92c1895b00967cb.tar.gz cpython-0919a1a07b061ef9a8a94cc1d92c1895b00967cb.tar.bz2 |
Part of SF patch #1513870 (the still relevant part) -- add reduce() to
functools, and adjust docs etc.
Diffstat (limited to 'Doc/howto/doanddont.tex')
-rw-r--r-- | Doc/howto/doanddont.tex | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/Doc/howto/doanddont.tex b/Doc/howto/doanddont.tex index a105ca1..df3ca34 100644 --- a/Doc/howto/doanddont.tex +++ b/Doc/howto/doanddont.tex @@ -289,19 +289,7 @@ There are also many useful builtin functions people seem not to be aware of for some reason: \function{min()} and \function{max()} can find the minimum/maximum of any sequence with comparable semantics, for example, yet many people write their own -\function{max()}/\function{min()}. Another highly useful function is -\function{reduce()}. A classical use of \function{reduce()} -is something like - -\begin{verbatim} -import sys, operator -nums = map(float, sys.argv[1:]) -print reduce(operator.add, nums)/len(nums) -\end{verbatim} - -This cute little script prints the average of all numbers given on the -command line. The \function{reduce()} adds up all the numbers, and -the rest is just some pre- and postprocessing. +\function{max()}/\function{min()}. On the same note, note that \function{float()}, \function{int()} and \function{long()} all accept arguments of type string, and so are |