Jonathan Fine writes:
Here's a baby example - searching in a nested loop. Suppose we're looking for the word 'apple' in a collection of books. Once we've found it, we stop.
While I was writing a reply, several people replied with very similar comments, so I won't repeat them. But these two examples are so obnoxious I had to post them:
for page in (page for book in books for page in book if 'a' in page):
... break ...
[page for book in books for page in book if 'a' in page]