sum and strings
Paddy
paddy3118 at netscape.net
Fri Aug 25 12:17:23 EDT 2006
Paddy wrote:
<<SNIP>>
> Why not make sum work for strings too?
>
> It would remove what seems like an arbitrary restriction and aid
> duck-typing. If the answer is that the sum optimisations don't work for
> the string datatype, then wouldn't it be better to put a trap in the
> sum code diverting strings to the reduce equivalent?
>
> Just a thought,
>
> - Paddy.
from __no_future__ import sum
assert "Not likely" == sum(["Not ", "likely"], "", least_surprise=True)
:-)
More information about the Python-list
mailing list