4 ms·
What's the benefit of prohibiting passing positional arguments by name?
by DangitBobby 3y ago
What's the benefit of prohibiting passing positional arguments by name?
- shrimpx 3y agoWhen args are positional-only, you can rename them without breaking callers. The names of the kwargs can be considered "external" and the names of the positional args remain private to the function. This gives authors flexibility to rename args, or even convert all the positional args to variadic `*args`, without affecting users. It also gives authors control over argument order. Like you write `def pow(x, y)`, conventionally meaning "x to the power y", and you don't want users to call it like `pow(y=2, x=3)`.