Asterisk sign in python

David M. Cooke cookedm+news at physics.mcmaster.ca
Thu Feb 26 16:47:08 EST 2004


At some point, "John Roth" <newsgroups at jhrothjr.com> wrote:

> "sarmin" <sarmin_kho at yahoo.com> wrote in message
> news:mailman.159.1077796055.8594.python-list at python.org...
>> Hi Pythoners...
>>
>> It seems to me the Asterisk (*) sign in python means many things...
>>
>> if a python code line looks like this:
>> def__init__(self, func, *param):
>>   bla bla bla...
>>
>> and then u have something like this:
>> func(*param)
>>
>> and then something like this:
>> def Wrapper(select, func, param):
>>    bla bla bla...
>>
>> I took this section of code from the 'Python Cookbook' textbook page
>> 223 about 'Running Functions in the future'...
>>
>> I just cant figure out what is the asterisk (*) sign for and what is
>> the different between *param and param??
>>
>> Many thanks Pythoners...
>>
>> Regards
>> sarmin
>
> It's for variable length parameter lists. In a function
> definition, one * is a list of additional positional
> parameters, two **s is a dictionary of additional
> keyword parameters.
>
> In a function call, one * is a list of additional
> positional parameters, two **s is a dictionary
> of additional keyword parameters.

Don't forget multiplicaton:

2 * 2

and power

2 ** 2

:-)

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca



More information about the Python-list mailing list