On Wed, Oct 27, 2021 at 5:30 AM Ricky Teachey <ri...@teachey.org> wrote: > But with function k below, where the b parameter is deferred, you can't get > the default b parameter by dynamically unpacking some values; you would have > to pass c as a kwd arg: > > def k(a, b=>len(a), c=None): > ... > > Seems like it would be- needed? convenient?- to be able to "ask" for the > default in a dynamic way... Am I making more of this than is justified? >
Question: Does it make sense to ask for the default for the second positional parameter, while passing an actual value for the third? If it does, then the function needs an API that reflects this. The most obvious such API is.... what you already described: passing c as a keyword argument instead. I don't think this is a problem. When you're looking at positional args, it is only ever the last N that can be omitted. If it makes sense to pass any combination of arguments, then they should probably be keyword-only, to clarify this. Do you have any examples where this isn't the case? ChrisA _______________________________________________ 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/LNPLIXKAD6NNKRU4BRLPS3YJLQSUEKRR/ Code of Conduct: http://python.org/psf/codeofconduct/