restriction on sum: intentional bug?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sat Oct 17 03:34:31 EDT 2009
On Fri, 16 Oct 2009 11:06:30 -0700, Jon Clements wrote:
> For instance, sum(['1', '2', '3']); it's not completely unreasonable for
> someone to expect
> a result of 6.
This is Python, not Perl -- Python never tries to perform numeric
arithmetic on strings. '1'+'2' will return '12' and not 3. It is
completely unreasonable to expect sum() to coerce strings to ints when
the + operator does not.
--
Steven
More information about the Python-list
mailing list