API Reference
better_sum.sum_starts_at_instance(*args, **kwargs)
Register a type's start value for sum.
| Parameters: |
|
|---|
better_sum.sum(__iterable, *maybe_start)
A type-aware extension replacing Python's built-in sum.
To use it, first register types by doing one of the following:
- Use the sum_starts_at_instance decorator
- Provide a
__sum_start__class attribute on a type
Both of these can get tricky, but the decorator is probably easier.
Python's built-in sum usually starts the accumulator value
at 0, but you can set it to anything you want with via its optional
positional start argument.
| Parameters: |
|
|---|