On Tue, Oct 26, 2021 at 2:40 PM Chris Angelico <ros...@gmail.com> wrote:
> 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 > I don't. I only have a niggling feeling that maybe this is a bigger problem than we're giving it credit for. If I can, I'll try to substantiate it better. Maybe others can better flesh out the concern here if it's valid. At bottom I guess I'd describe the problem this way: with most APIs, there is a way to PASS SOMETHING that says "give me the default". With this proposed API, we don't have that; the only want to say "give me the default" is to NOT pass something. I don't KNOW if that's a problem, it just feels like one. --- Ricky. "I've never met a Kentucky man who wasn't either thinking about going home or actually going home." - Happy Chandler
_______________________________________________ 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/57JDHXLKZGK6G6WYVAQDN46XWW35ORYG/ Code of Conduct: http://python.org/psf/codeofconduct/