sum and strings

neophyte spamfranke at web.de
Wed Aug 23 16:34:31 EDT 2006


Fredrik Lundh wrote:
> do you often write programs that "sums" various kinds of data types, and
> for which performance issues are irrelevant?
>
> or are you just stuck in a "I have this idea" loop?

Maybe he's just insisting on the principle of least surprise?
Personally, I'd rather expect sum() to work for strings and Python to
issue a warning instead of raising a type error. That warning might
also be appropriate when using sum() on other builtin sequence types.




More information about the Python-list mailing list