On Oct 28, 2019, at 14:23, Serhiy Storchaka <storch...@gmail.com> wrote:
> 
> 28.10.19 20:38, Andrew Barnert via Python-ideas пише:
>> Many of them are abusing throw(StopIteration) to fake a “takewhile clause” 
>> in comprehensions
> 
> Well, so actually you needed the break expression. Or multistatement 
> comprehension.

Well, what I really (thought I) needed was a more concise way to do the 
equivalent of takewhile and friends, and I still think the ideal solution there 
is a general way to write concise lambdas or the equivalent using a great new 
syntax that nobody has been able to come up with yet in any of the times the 
idea has been discussed. :)

Faking it by raising StopIteration in the middle of the value expression or an 
if clause seemed like a clever workaround, albeit only for takewhile. But it 
actually has a lot of problems; various things that shouldn’t change your 
semantics do if you’re using this hack. (For example, chain up a few 
throw-breaking genexprs, then change one of the intermediate ones to a listcomp 
so you can see it in the debugger.) So, I’d already abandoned it before the PEP 
that broke it.

Would a break expression be able to give me the same benefits without the 
problems? Maybe. But I honestly haven’t missed the throw(StopIteration) hack 
enough to experiment with that idea when people suggested it.

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

Reply via email to