restriction on sum: intentional bug?
joncle at googlemail.com
Sat Oct 17 03:01:41 CEST 2009
On Oct 17, 1:16 am, Terry Reedy <tjre... at udel.edu> wrote:
> Alan G Isaac wrote:
> > As Tim explained in detail, and as Peter
> > explained with brevity, whether it will
> > happen or not, it should happen. This
> > conversation has confirmed that current
> > behavior is a wart: an error is raised
> > despite correct semantics. Ugly!
> The fact that two or three people who agree on something agree on the
> thing that they agree on confirms nothing. One could just as well argue
> that summing anything but numbers is semantically incoherent, not
> correct. Certainly, my dictionary points in that direction.
I agree here. I don't think it's a case of "warning about
inefficiency" that Python
doesn't sum strings, but rather that 'summing' strings doesn't make
An OTT example could be sum(['010111010', '372']) # Binary and decimal
Sum should return a *numeric* result, it has no way to do anything
with strings -- that's up to the coder and I think it'd be an error in
to not raise an error.
More information about the Python-list