On 2020-05-26 20:22, Chris Angelico wrote:
On Wed, May 27, 2020 at 5:19 AM Alex Hall
wrote: On Tue, May 26, 2020 at 9:05 PM Chris Angelico
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.
Unless it was already bound, in which case it would still have that value. Best to initialise it for safety.