Remix.run Logo
DaiPlusPlus 2 days ago

To me, “keyword arguments” means actual language keywords being used as arguments, like “minute” or “hour” in T-SQL’s DATEDIFF, for example: `SELECT DATEDIFF( hour, NOW(), someDateCol )`.

…but I think the author meant “named arguments”, like we have in C#, Swift, and Objective-C.

akoboldfrying 2 days ago | parent | next [-]

I think the author meant "keyword arguments", like they're called in Python, and which they mentioned in the first sentence.

https://docs.python.org/3/glossary.html?hl=en-GB#term-keywor...

rileymat2 2 days ago | parent | prev [-]

Python calls them keyword arguments.

tonyarkles 2 days ago | parent | next [-]

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'}
cenamus 2 days ago | parent | prev | next [-]

And I suppose Lisp started that with :key args

antonvs 2 days ago | parent | prev [-]

Python’s perversity is fractal.