[Python-ideas] Is this PEP-able? for X in ListY while conditionZ:
Ron Adam
ron3200 at gmail.com
Wed Jun 26 04:43:54 CEST 2013
On 06/25/2013 04:08 PM, jimjhb at aol.com wrote:
> That would bring back my previous notion of fwhile.
>
> fwhile X in ListY and conditionZ:
>
> It was pointed out that the 'and' is ambiguous (though perhaps not fatally
> problematic)
> and adding a new keyword is really bad as well.
>
> I guess:
>
> for X in ListY and conditionZ: would just have the ambiguity.
>
> [Or maybe not, as long as the condition is a bool, it's not iterable and
> thus not confused with list.]
What about allowing break and continue in if/else expressions?
In a loop it might look like...
break if n>=42 else continue
In a comprehension it would be...
[ (x if x<10 else break) for x in range(20) ]
There has been some interest in adding 'break if condition'. But I think
this would be better.
Cheers,
Ron
More information about the Python-ideas
mailing list