[Python-ideas] Allowing breaks in generator expressions by overloading the while keyword

Antoine Pitrou solipsis at pitrou.net
Sat Feb 22 00:10:10 CET 2014


On Sat, 22 Feb 2014 11:58:40 +1300
Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Antoine Pitrou wrote:
> > But on the contrary, trying to compress control flow in a single line
> > breaks the visual structure expectation for Python code (in which most
> > control flow is introduced by a colon and a linefeed).
> 
> We've had control flow in expressions for a long time. The
> 'and' and 'or' operators affect control flow, but nobody
> complains that they "break the visual flow".

You can easily think of them as shortcutting operators.
Doing the same with "break" isn't possible.

Regards

Antoine.




More information about the Python-ideas mailing list