[Tutor] Some question about OO practice
Kent Johnson
kent37 at tds.net
Sun Nov 4 15:11:59 CET 2007
John wrote:
> Thanks,
>
> One last question (okay, one MORE question ;) ) when you call a
> method/function with optionaly *args **kwargs, I'm finding I need to
> make the statement like;
>
> def myFunc(self, *args,**kwargs):
> do something
>
>
> In ord to pass the kwargs:
> myFunc(**kwargs) # where kwargs is a dictionary
>
> or for args:
> myFunc(a,b,c, etc.)
>
> It is correct that you need to use the '**' in the 'calling' statement?
Yes, if the keyword args are in a dict you have to use ** at the point
of call. You can also specify the args directly:
myFunc(x=1, y=2)
Kent
More information about the Tutor
mailing list