Skip to content
Myr

Improved documentation for sum

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent b7e75b8 · Browse files · 1 file+10 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−2 removed

  • other:+10 added−2 removed

1 file+10 added−2 removed

modified:jinja2/filters.py+10 added-2 removed
646 unmodified lines
647648649@environmentfilter650def do_sum(environment, iterable, attribute=None, start=0):651 """Sums up an iterable.651 """Returns the sum of a sequence of numbers plus the value of parameter652 'start' (which defaults to 0). When the sequence is empty it returns653 start.654655 It is also possible to sum up only certain attributes:656657 .. sourcecode:: jinja658659 Total: {{ items|sum(attribute='price') }}660661 .. versionchanged:: 2.6662 The `attribute` parameter was added to allow suming up over655 attributes.663 attributes. Also the `start` parameter was moved on to the right.664 """665 if attribute is not None:666 iterable = imap(make_attrgetter(environment, attribute), iterable)667 return sum(iterable, start)
110 unmodified lines