Hi, Luis Zarrabeitia wrote:
Quoting Laszlo Nagy <[EMAIL PROTECTED]>:
...
Even better: help(sum) shows === sum(...) sum(sequence, start=0) -> valueReturns the sum of a sequence of numbers (NOT strings) plus the valueof parameter 'start'. When the sequence is empty, returns start. === so the fact that sum([]) returns zero is just because the start value is zero... sum([],object()) would return an object(). BTW, the original code:sum(s for s in ["a", "b"] if len(s) > 2)wouldn't work anyway... it seems that sum doesn't like to sum strings:sum(['a','b'],'')<type 'exceptions.TypeError'>: sum() can't sum strings [use ''.join(seq) instead]
Yes which is a bit bad anyway. I don't think hard wiring it is such a nice idea. You know, walks like a duck, smells like a duck...
If it makes sense to handle things differently for performance, then please have it doing it silently, e.g. when it detects strings just use join() internally. Cheers Tino
smime.p7s
Description: S/MIME Cryptographic Signature
-- http://mail.python.org/mailman/listinfo/python-list