On Fri, Dec 06, 2019 at 10:24:30AM +0200, Serhiy Storchaka wrote:

> In real code this can be a fragment of the larger function and look like:
> 
>         for item in jsonld_items:
>             if item['@type'] == 'Product':
>                 break
>         else:
>             item = {}

Sure, but in this case, it isn't a fragment of a larger function, and 
that's not what it looks like. If it looked like what you wrote, I would 
understand it. But it doesn't, so I didn't really understand what it was 
supposed to do, until I read the equivalent version using first/next.

One unfortunate side-effect of the choice of "else" as keyword in 
`for-else` is that if the last statement in the `for` block is an `if`, 
it looks like the `else` is wrongly indented.



-- 
Steven
_______________________________________________
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/QXJ4RXHWYIXRTACMXMRFBS5ZOXZJJK64/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to