On Sun, Dec 5, 2021 at 3:17 PM David Mertz, Ph.D. <david.me...@gmail.com> wrote:
>
> On Sat, Dec 4, 2021, 11:13 PM Chris Angelico
>>
>> Not sure I'm understanding you correctly; in what way are named parameters 
>> relevant here?
>
>
> def add(a, b):
>     return a+b
>
> How could you write that differently with your PEP

I wouldn't. There are no default arguments, and nothing needs to be changed.

> (which only pertains to named parameters, not positional)?

Actually PEP 671 applies identically to arguments passed by name or
position, and identically to keyword-only, positional-or-keyword, and
positional-only parameters.

>>> def f(a=>[], /, b=>{}, *, c=>len(a)+len(b)):
...     print(a, b, c)
...
>>> f()
[] {} 0
>>> f([1,2,3])
[1, 2, 3] {} 3
>>> f(b={"a":1})
[] {'a': 1} 1
>>> f(c=42)
[] {} 42
>>>

You can put early-bound or late-bound defaults on all three types of
parameter, and you can either provide or omit both kinds of argument;
the entire matrix has always been possible [1], and the entire matrix
will continue to be possible.

ChrisA
[1] For values of "always" that go back as far as PEP 570, at least,
since that's when pos-only params came in. Before that, it was a 2x2
matrix.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/NRU4C7V2LKLA6WON6UC5IYS3A62D5H2Z/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to