3 ms·
In Python, by default you can use keyword arguments for any function parameter. And if you want, you can make arguments keyword-only: def copyFile(*, source
by istjohn 7y ago
In Python, by default you can use keyword arguments for any function parameter.
And if you want, you can make arguments keyword-only:
def copyFile(*, source, dest):
...
Parameters after the asterisk cannot be specified by positional arguments. It must be called with keyword arguments:
copyFile(source=src, dest=dst)
- jjoonathan 7y agoPython's kwargs are still optional in the sense that I care about. Same goes for many other kwarg-supporting languages. The strategy you propose can only force other people to use kwargs when calling functions you write. When you're reading code, there is no guarantee that arguments to functions you didn't write will be labeled, and indeed they often aren't, even when they ought to be. In ObjC, all arguments are labeled, always. It's heavily opinionated, and the experience is qualitatively different as a result.