Function params with **? what do these mean?
iddw at hotmail.com
Tue Mar 21 01:06:29 CET 2006
On 20 Mar 2006 15:45:36 -0800 in comp.lang.python,
aahz at pythoncraft.com (Aahz) wrote:
>In article <r56u12pb4ajvhshvh40slb80di1bfeiagr at 4ax.com>,
>Dave Hansen <iddw at hotmail.com> wrote:
>>It's harder to explain than understand. Try playing with the
>>following function in the python interpreter:
>> def test(a,b='b', *c, **d):
>> print a,b,c,d
>Personally, I think it's a Good Idea to stick with the semi-standard
>names of *args and **kwargs to make searching easier...
Agreed (though "kwargs" kinda makes my skin crawl). I don't use these
features often in my code, but when I do, I follow the convention. The
example was just for illustrative purposes, and the names chosen for
It is important to note that using "args" and "kwargs" is a convention
rather than a requirement, analogous to "self". You can use different
identifiers, but future maintainers of your code will be annoyed.
But it won't affect the operation of the code. I found the test case
"test(a=1,b=2,c=3,d=4)" to be most edifying.
Change is inevitable, progress is not.
More information about the Python-list