[Tutor] A list of input arguments
alan.gauld at btinternet.com
Tue Jan 13 22:20:10 CET 2009
"Kent Johnson" <kent37 at tds.net> wrote
>>> Is there any way to list the input arguments without listing them
>>> the function's parentheses?
>> No, because the function expects 3 arguments so you must pass it 3.
> You can use *args to pass multiple arguments in a list. For example,
> In : values = [1, 2, 3]
> In : show(*values)
> 1 2 3
Thats true although I read the question as meaning can I pass in an
arbitrary list of arguments even though the function takes 3... The
follow-on question seemed to back up that understanding. But it
could mean what you took it for in which case clearly the answer
is yes and *chords would have worked.
I cobfess I don;t like the *args style where the function takes a
number of params because I find it too easy to hide bugs by
passing the wrong number of args. Explicit is better etc...
Author of the Learn to Program web site
More information about the Tutor