3 ms·
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( h
by DaiPlusPlus 4mo 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.
- rileymat2 4mo agoPython calls them keyword arguments.
- antonvs 4mo agoPython’s perversity is fractal.
- cenamus 4mo agoAnd I suppose Lisp started that with :key args
- tonyarkles 4mo agoThey 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'}
- akoboldfrying 4mo agoI 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-keyword-argument https://docs.python.org/3/glossary.html?hl=en-GB#term-keywor...