[Tutor] A list of input arguments
Kent Johnson
kent37 at tds.net
Tue Jan 13 12:42:40 CET 2009
On Tue, Jan 13, 2009 at 4:16 AM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> "Mr Gerard Kelly" <s4027340 at student.uq.edu.au> 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.
> That is the contract (or interface) that exists betweeen the writer of the
> function and you the consumer of it. Programming. particularly on
> larger projects with multiple teams, is all about defining interfaces
> and adhering to them! If you want thebenefit of the function you must
> respect its contract.
You can use *args to pass multiple arguments in a list. For example,
In [1]: def show(a, b, c):
...: print a, b, c
In [2]: values = [1, 2, 3]
In [3]: show(*values)
1 2 3
Kent
More information about the Tutor
mailing list