mirror of
https://github.com/python/cpython.git
synced 2025-08-21 09:21:18 +00:00
Issue 7447: Improve docs for sum().
This commit is contained in:
parent
490986308e
commit
15c2cec4fd
1 changed files with 7 additions and 4 deletions
|
@ -1227,10 +1227,13 @@ available. They are listed here in alphabetical order.
|
||||||
|
|
||||||
Sums *start* and the items of an *iterable* from left to right and returns the
|
Sums *start* and the items of an *iterable* from left to right and returns the
|
||||||
total. *start* defaults to ``0``. The *iterable*'s items are normally numbers,
|
total. *start* defaults to ``0``. The *iterable*'s items are normally numbers,
|
||||||
and are not allowed to be strings. The fast, correct way to concatenate a
|
and the start value is not allowed to be a string.
|
||||||
sequence of strings is by calling ``''.join(sequence)``. Note that
|
|
||||||
``sum(range(n), m)`` is equivalent to ``reduce(operator.add, range(n), m)``
|
For some use cases, there a good alternatives to :func:`sum`.
|
||||||
To add floating point values with extended precision, see :func:`math.fsum`\.
|
The preferred, fast way to concatenate a sequence of strings is by calling
|
||||||
|
``''.join(sequence)``. To add floating point values with extended precision,
|
||||||
|
see :func:`math.fsum`\. To concatenate a series of iterables, consider using
|
||||||
|
:func:`itertools.chain`.
|
||||||
|
|
||||||
.. versionadded:: 2.3
|
.. versionadded:: 2.3
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue