On Tue, May 26, 2020 at 9:24 PM Chris Angelico <ros...@gmail.com> wrote:
> On Wed, May 27, 2020 at 5:19 AM Alex Hall <alex.moj...@gmail.com> wrote: > > > > On Tue, May 26, 2020 at 9:05 PM Chris Angelico <ros...@gmail.com> wrote: > >> > >> And the "is this name bound" check would potentially > >> have other value, too. > > > > > > Can you think of any examples? > > When you're looping, searching for something, and then seeing if you > found any. If you want to stop at the first, you can use 'break' and > 'else' (although a lot of people don't know about that), but what if > you're locating the last match, and can't search in reverse? Or some > sort of best match or all match? How do you then say "none found"? > Usually you end up needing a sentinel, but if you could simply leave > the variable unbound, you could then check for that at the end. > > ChrisA This proposal would still leave defaults out of the signature, and thus the only benefit I'm seeing is being able to avoid typing `if obj is sentinel`. In fact it saves even less typing than other proposals since you still have to write `obj ?= value`. I don't think that's a significant benefit, and others have expressed similar. So is there any use for it which can't be satisfied by a sentinel? Otherwise I would definitely prefer None-aware operators from PEP 505.
_______________________________________________ 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/FC4H57ZRO72BTWCWB6FHO2IHWQXSOZGZ/ Code of Conduct: http://python.org/psf/codeofconduct/