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)

:-)

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to