Parsing Strings in Enclosed in Curly Braces

Aahz aahz at pythoncraft.com
Sat May 16 11:28:02 EDT 2009


In article <180531ca-33aa-47b9-9c69-5b5973f6b6f9 at v35g2000pro.googlegroups.com>,
John Machin  <sjmachin at lexicon.net> wrote:
>
>Neat trick. However, from 2.6.2:
>
>>>> help(sum)
>Help on built-in function sum in module __builtin__:
>
>sum(...)
>    sum(sequence[, start]) -> value
>
>    Returns the sum of a sequence of numbers (NOT strings) plus the
>value
>    of parameter 'start' (which defaults to 0).  When the sequence is
>    empty, returns start.
>
>Since when is a list a number? Perhaps the help needs clarification,
>in line with the docs.

The primary use-case for sum() is numbers, with a special exception to
prohibit using strings.  Only strings are prohibited to allow using sum()
with user-defined classes.  That makes it a little difficult to document
precisely in a summary; unless you can come up with a specific better
wording, the docs will probably stay as-is.  If you do come up with
something better, please file it on bugs.python.org.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"In 1968 it took the computing power of 2 C-64's to fly a rocket to the moon.
Now, in 1998 it takes the Power of a Pentium 200 to run Microsoft Windows 98.
Something must have gone wrong."  --/bin/fortune



More information about the Python-list mailing list