
On Tue, Oct 26, 2021, 9:54 PM Rob Cliffe via Python-ideas < python-ideas@python.org> wrote:
On 27/10/2021 01:47, Chris Angelico wrote:
The idea that a parameter is optional, but doesn't have a value, may itself be worth exploring (maybe some way to say "arg=pass" and then have an operator "if unset arg:" that returns True if it's unbound), but that's for another day.
ChrisA Indeed. And it could be useful to know if a parameter was passed a value or given the default value. Python has very comprehensive introspection abilities, but this is a (small) gap. Rob Cliffe
I'll try to summarize why I still have pause even though after thinking about it I still can't really think of a solid example showing that this "give me the default" issue is a concrete problem: Until this point, exactly how to provide a default argument value has been the Wild West in python, and as Paul Moore said, there's really not a way to introspect whether a parameter was "defaulted". The result is that a cornucopia of APIs have flourished. By necessity, all these previous APIs provided ways to ask for the default through passing some special value, and this has felt like "the pythonic way"for a night time. We are all used to it (but perhaps only tolerated it in many cases). The proposal blesses a new API with language support, and it will suddenly become THE pythonic approach. But this newly blessed, pythonic API is a radical departure from years- decades- of coding habits. And so even though I like the proposal, I'm just concerned it could be a little bit more painful than at first glance. So it just seems like some version of these concerns belongs in the PEP. Thanks Chris A for putting up with what isn't much more than a hunch (at least on my part) and I'll say nothing more about it. Carry on.