[Tutor] Class Tips
David
david at abbottdavid.com
Sun May 31 11:01:30 CEST 2009
ALAN GAULD wrote:
>
>> but I get an error here;
>>
>> def main():
>> frate = FertRate(get_inputs())
>
>
>> File "./fert_class.py", line 15, in main
>> frate = FertRate(get_inputs())
>> TypeError: __init__() takes exactly 5 arguments (2 given)
>
>
> Sorry my mistake. Because get_inputs() returns a tuple
> you have to tell the function to unpack it by placing an
> asterisk in front of the function call:
>
> frate = FerrtRate( *get_inputs() )
>
> That should work now.
>
> Alan G.
>
>
Super, I had seen that in other programs and now I know why.
I have used;
def c(*args, **kwargs):
My understanding is 'args' is a tuple with all the positional arguments,
kwargs is a dictionary with all the named arguments.
--
Powered by Gentoo GNU/Linux
http://linuxcrazy.com
More information about the Tutor
mailing list