Hello.
Came here to express my disturbance about development of Python language, especially about inconsistency of it’s syntax to current args kwargs - related syntax.
I’m about using / to delimit positional args, * to delimit keywords.
As to unpack positional args (actually - tuples) we use *, and for keyword args - **; I would understand if we would use it for delimiting positional args from keyword-positional and pure keyword args.
It should look like so:
def some_func(a, b, *other_args, *, c=None, d=None, **, e=None, f=None, **other_kwargs):
pass
where a, b - are pure positional args; c, d - can be or positional or keyword args; e, f - keyword args, and other_args, other_kwargs gather all additional positional and keyword args.
I’m really sad that my favorite language with pure syntax and consistent semantics gets overpopulated by inconsistency.
Sources:
Docs to Python 3.8: https://docs.python.org/3/whatsnew/3.8.html
PEP 570: https://www.python.org/dev/peps/pep-0570/
My comments:
it's kind of the opposite of '*' which means "keyword argument"
- no, it’s not so. * is used to unpack tuples and lists, or pack positional args to tuple.
def pos_only_arg(arg, /):
should lool like so: def pos_only_arg(arg, *):
def kwd_only_arg(*, arg):
should lool like so: def kwd_only_arg(**, arg):
Hope, this could be fixed eventually.
Best regards,
Vladislav