What's the difference between arguments with default values and keyword-arguments?

Posted by o_O Tync on Stack Overflow See other posts from Stack Overflow or by o_O Tync
Published on 2011-01-12T01:48:54Z Indexed on 2011/01/12 1:53 UTC
Read the original article Hit count: 616

Filed under:
|

In Python, what's the difference between arguments having default values:

def f(a,b,c=1,d=2): pass

and keyword arguments:

def f(a=1,b=2,c=3): pass

? I guess there's no difference, but the tutorial has two sections:

4.7.1. Default Argument Values

4.7.2. Keyword Arguments

which sounds like there are some difference in them. If so, why can't I use this syntax in 2.6:

def pyobj_path(*objs, as_list=False): pass

?

© Stack Overflow or respective owner

Related posts about python

Related posts about syntax