Follow

A pro-tip: prepend a `*` at the beginning of a function's signature to make the function kwargs-only. (Python 3 only.)

>>> def f(*, x):
... return x
...
>>> f(x=42)
42
>>> f(42)
[...]
TypeError: f() takes 0 positional arguments but 1 was given

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!