[Python-ideas] SyntaxWarning for for/while/else without break or return?

Stefan Rank list-ener at strank.info
Thu Oct 8 10:57:38 CEST 2009


a suggestion/question related to the discussion about renaming for/else 
and while/else:
Is it easy to generate a SyntaxWarning if you use these constructs 
without a break or return statement in the loop? AFAICS, any such usage 
would be either wrong or unnecessary. (right?)

This would both help prevent wrong usage because of a false intuition 
and, if adequately and prominently documented, would help those 
interested in learning about for/else while/else.

Easily doable? Maybe even make it a SyntaxError?
I guess it would involve using a flag while parsing loops, but that's 
why I am asking, since I don't have experience with Python's parser...


More information about the Python-ideas mailing list