[Tutor] A list of input arguments
Alan Gauld
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
>>> inside
>>> 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 [2]: values = [1, 2, 3]
>
> In [3]: 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
specified
number of params because I find it too easy to hide bugs by
inadvertantly
passing the wrong number of args. Explicit is better etc...
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list