On Mar 15, 2005, at 01:16, Tim Peters wrote: > [Eric Nieuwland] >>> Perhaps the second argument should not be optional to emphasise this. >>> After all, there's much more to sum() than numbers. > > [Greg Ewing] >> I think practicality beats purity here. Using it on >> numbers is surely an extremely common case. > > I'd personally be delighted if sum() never worked on anything other > than numbers. That makes it easy to understand, easy to document, > easy to remember, obvious at first sight, and straightforward to > implement. Everything a framework isn't, but it's not a bad thing to > have *something* that actually means exactly what it looks like it > says <0.5 wink>. I'm reasonably often using sum on lists of datetime.timedelta instances, "durations", which ARE summable just like numbers even though they aren't numbers. I believe everything else for which I've used sum in production code DOES come under the general concept of "numbers", in particular X+0 == X. Unfortunately, this equation doesn't hold when X is a timedelta, as X+0 raises an exception then. Alex
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4