On 25/07/2017 06:51, Nick Coghlan wrote: > On 25 July 2017 at 02:23, Ben Hoyt <benhoyt at gmail.com> wrote: >> This is more of a python-ideas discussion, and Steven's answer is good. >> >> I'll just add one thing. Maybe it's obvious to others, but I've liked >> for...else since I found a kind of mnemonic to help me remember when the >> "else" part happens: I think of it not as "for ... else" but as "break ... >> else" -- saying it this way makes it clear to me that the break goes with >> the else. "If this condition inside the loop is true, break. ... *else* if >> we didn't break, do this other thing after the loop." > For folks looking for a more in-depth explanation of the > "if-break-else" approach to thinking about this construct: > http://python-notes.curiousefficiency.org/en/latest/python_concepts/break_else.html A helpful explanation. But that it is necessary at all underlines that (IMHO) this use of 'else' is unnatural and hard to understand. I always have to think twice about it, whether reading it or using it myself. Therefore I would have preferred a more obvious keyword such as 'ifnobreak' (others may think of something better). But as has been stated, it's not going to change. Rob Cliffe > > That article also has a note explaining that we're unlikely to ever > change this: http://python-notes.curiousefficiency.org/en/latest/python_concepts/break_else.html#but-couldn-t-python-be-different > > Cheers, > Nick. >
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4