On Thu, Dec 2, 2021 at 2:40 PM Chris Angelico <rosuav@gmail.com> wrote:
How is a late-bound default different from half of a conditional expression?
 
 def f(lst=>[], n=>len(lst)): 

def f(*args):
    lst = args[0] if len(args) > 0 else []
    n = args[1] if len(args) > 1 else len(lst)     

Although such is obviously not your intention, I think you have provided a stronger argument against this feature/PEP than any other I've seen raised so far.  Well, maybe just against the specific implementation you have in mind.

You are correct, of course, that the second form does not provide inspectability for `lst` and `n`.  Well, it does, but only in a fairly contorted way of disassembling f.__code__.co_code.  Or maybe with an equally indirect look at the parse tree or something.  The body of a function is very specifically A BODY.

What your proposal/implementation does is put things into the function signature that are simultaneously excluded from direct inspectability as function attributes. Python, like almost all programming languages, makes a pretty clear distinction between function signatures and function bodies.  You propose to remove that useful distinction, or at least weaken it.

For the reasons Eric Smith and others have pointed out, I really WANT to keep inspectability of function signatures.

--
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.