Creating variables on the fly...
Brendan Hahn
bhahn at spam-spam.g0-away.com
Mon Apr 3 19:53:05 EDT 2000
Matthew Hirsch <meh9 at cornell.edu> wrote:
>I like this solution. How do I use the apply function in the body to
>call add()? (I won't know ahead of time how many arguments are going in
>the function).
You would "apply(add, list-or-tuple-full-of-arguments)". You don't really
need a separate add-up-a-list function, though, you can use reduce:
"reduce(operator.add, list-or-tuple-full-of-arguments)".
bhahn at transoft.mmangle.net <-- unmangle address to reply
More information about the Python-list
mailing list