sum and strings
Fredrik Lundh
fredrik at pythonware.com
Thu Aug 24 02:17:45 EDT 2006
Tim Chase wrote:
> >>> q3 = q1 + q2
> >>> q3.n, q3.i, q3.j, q3.k
> (8, 13, 16, 22)
> >>> sum([q1,q2])
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: unsupported operand type(s) for +: 'int' and 'q'
>
> Just because something is slow or sub-optimal doesn't mean it
> should be an error.
that's not an error because it would be "slow or sub-optimal" to add
custom objects, that's an error because you don't understand how "sum"
works.
(hint: sum != reduce)
</F>
More information about the Python-list
mailing list