logoalt Hacker News

tonyarklestoday at 5:14 AM0 repliesview on HN

They do, but they're also not strictly required to be named explicitly:

They can be:

    >>> def foo(bar=None):
    ...   print(bar)
    ...
    >>> foo()
    None
    >>> foo(bar="baz")
    baz
    >>> foo(bar="baz", baz="azp")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: foo() got an unexpected keyword argument 'baz'
But you can also use them generically:

    >>> def bar(**kwargs):
    ...   print(kwargs)
    ...
    >>> bar()
    {}
    >>> bar(site="HN", user="tonyarkles")
    {'site': 'HN', 'user': 'tonyarkles'}