On Tue, May 26, 2020 at 8:30 PM Greg Ewing <greg.ew...@canterbury.ac.nz> wrote:
> "Did the user supply a value for this optional argument?" is > a simple and reasonable question to ask. It deserves to have a > simple and direct way of answering it that always works. > It does so very little that I would definitely not want syntax ONLY for that. The example of lru_cache() is god here... None is a sentinel, but it is NOT the default value. So there is a value of 128 supplied, even if the user doesn't supply one. Changing syntax for something that doesn't even actually save a line, isn't worth it. I'm assuming you mean something along the lines of: def foo(a, b, mode=): if undef mode: mode = whatever It's really just a sentinel, no better than None. If we want to save more, we're back to PEP 505 and None-coalescing. I'm feeling more sympathetic to that than I did in earlier discussion. But I'm still a bit horrified by some of the use cases that were presented at that time (not directly in the PEP). E.g.: data = json.load(fh) needle ?= data?.child?.grandchild?[key]?[index]?.attr When it looks like that, I get visions of APL or Perl unreadability. So I guess what I'm sympathetic with is about 1/3 of PEP 505. Like only: stuff = this ?? that Yes, there are still rare non-None sentinels to deal with differently, but that is 90% of the issue being discussed. -- The dead increasingly dominate and strangle both the living and the not-yet born. Vampiric capital and undead corporate persons abuse the lives and control the thoughts of homo faber. Ideas, once born, become abortifacients against new conceptions.
_______________________________________________ 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/XBA4VCCRP4LLVZ3S7JYBZMDADF3C4ZPS/ Code of Conduct: http://python.org/psf/codeofconduct/