On Wed, Feb 11, 2015 at 7:27 AM, boB Stepp <[email protected]> wrote:
>
> pass_args = {'a': (x1, x2, x3), 'b': (y1, y2), 'c': (z)}
> call_fcn[key_letter](key_letter)
>
> But ran into the syntax error that I was giving one argument when
> (possibly) multiple arguments are expected.

Do it like this:

    pass_args = {
        'a': (x1, x2, x3),
        'b': (y1, y2),
        'c': (z,),
    }

    call_fcn[key_letter](*pass_args[key_letter])

Note the 'c' tuple is written as (z,). A comma is required to create a
tuple. Also note the call uses the "* expression" syntax to merge an
iterable with the call's positional arguments. For example, f(x0,
*(x1,x2,x3)) is equivalent to f(x0, x1, x2, x3). Refer to the glossary
definition of "argument", and for a more detailed discussion, see the
section on calls in the language reference.

https://docs.python.org/2/glossary.html#term-argument
https://docs.python.org/2/reference/expressions.html#calls
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to