[Python-ideas] for/else statements considered harmful

MRAB python at mrabarnett.plus.com
Thu Jun 7 03:27:14 CEST 2012


On 07/06/2012 02:02, Andre Roberge wrote:
> On Wed, Jun 6, 2012 at 9:53 PM, Nick Coghlan <ncoghlan at gmail.com
> <mailto:ncoghlan at gmail.com>> wrote:
>
>     On Thu, Jun 7, 2012 at 9:58 AM, Bruce Leban <bruce at leapyear.org
>     <mailto:bruce at leapyear.org>> wrote:
>      > If we could go back in time I would completely agree. But since
>     we can't,
>      > flipping meaning of else would be too error inducing and
>     therefore not at
>      > all likely.
>
> SNIP
>
>
>     If anything were to change at the language level, my preference would
>     be
>
> SNIP
>
> My preference would be for a new keyword: nobreak
>
> This would work well with for/else and while/else which would become
> for/nobreak and while/nobreak
>
> I think that anyone reading
>
> while ...
>     ....
> nobreak:
>     some statements
>
> would (more) immediately understand that "some statements" are going to
> be executed if no break occurred in the above block.
>
> But I doubt that something like this will ever be considered even though
> it could be introduced now without breaking any code (other than that
> which uses "nobreak" as a variable ... which should be rare) by making
> it first a duplicate of the for/else and while/else construction which
> would be slowly deprecated.
>
How about "not break"? :-)



More information about the Python-ideas mailing list