News for hackers. Stuff that matters.
Re:A Python Guide for the Ages by nneonneo on Saturday December 25, 2021 @03:14AM (#29681433)
Yeah, the biggest risk with for-else is that some inexperienced dev comes along and misreads the else as belonging to an if statement inside the for (or, worse, attempting to “fix” it). I’ve seen this happen more than once…
Re:A Python Guide for the Ages by xmcqdpt2 on Saturday December 25, 2021 @07:44AM (#29682824)
Yes I always comment on it for this reason, sometimes (if I know the code will be maintained by someone with less python experience) with a link to the standard doc.

It's actually a super useful pattern for any kind of search iteration. I've used it many times.