[Tutor] Check Number of Parameters Passed In
Kent Johnson
kent37 at tds.net
Mon Jul 14 04:25:21 CEST 2008
On Sun, Jul 13, 2008 at 9:05 PM, bob gailer <bgailer at gmail.com> wrote:
> As an alternative to Kent's suggestion consider:
>
> def foo(parameter, *args)
>
> args will be a tuple with 0, 1 or more items in it.
>
> So you can test for len(args) == 1
Presumably the OP wants to distinguish between op1 and op2, so my guess is that
def foo(parameter, **kwargs)
would be more appropriate. (kwargs will be a dict containing any
keyword parameters.)
Kent
More information about the Tutor
mailing list