Difference between default arguments and keyword arguments

Josiah Carlson jcarlson at uci.edu
Mon Apr 5 19:26:56 EDT 2004


>>Functions implemented in C do not always have the property that every 
>>argument is a keyword argument. Functions implemented in Python do have 
>>that property. It's an implementation quirk.
> 
> Really?
> 
>     def foo(*args):
>         pass
> 
>     foo(x=1)
> 
> Traceback (most recent call last):
>   File "x.py", line 4, in ?
>     foo(x=1)
> TypeError: foo() got an unexpected keyword argument 'x'


Really.  It just so happens that foo doesn't take any keyword arguments, 
nor does it have an argument named 'x'.

  - Josiah



More information about the Python-list mailing list