sum() requires number, not simply __add__
arnodel at gmail.com
Thu Feb 23 16:32:43 EST 2012
On 23 February 2012 21:19, Buck Golemon <buck at yelp.com> wrote:
> I feel like the design of sum() is inconsistent with other language
> features of python. Often python doesn't require a specific type, only
> that the type implement certain methods.
> Given a class that implements __add__ why should sum() not be able to
> operate on that class?
It can. You need to pass a second argument which will be the start
value. Try help(sum) for details.
More information about the Python-list