|
|
|
|
|
by apple1417
474 days ago
|
|
Reading the PEP for adding it, it seems primarily concerned with mirroring how the C builtins generally don't allow it, for performance. https://peps.python.org/pep-0570/#rationale That being said, you can find quite a lot of uses in the modules written in Python - though I'm not going to pretend I can tell you the reasoning for all them. grep "/\s*[,)]" /usr/lib/python3.13/ --recursive --include "*.py" --exclude-dir site-packages
In my own code, the main use I've found is that they don't "reserve" a slot in kwargs - this is totally valid code: def func(x, /, **kwargs):
print(x, kwargs)
func(1, x=2)
You could've worked around it by taking a dict before, but it's just a lot friendlier being able to take args as normal. |
|