"Carl Banks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Just to play Devil's advocate, there is one draw drawback to "such | elegance": when there are multiple break statements. Which means | you'd have to duplicate the break-only condition, or refactor somehow | (which may or may not be suitable).
Yes, I knowingly glided over the possibility of multiple break statements with common break-only code and no completion-only code (other than artifactual flag setting as in your code below ;-). I presume that that triple condition is even rarer than simpler situations where one of those conditions is false. | There have been a couple occasions where I felt the best solution was | to a temporary varible like so: But I will accept your testimony that the set of such use cases is not empty. | completed = False | while loop_condition: | <loop statements> | if break_condition: | break | <more loop stuff> | if some_other_break_condition: | break | <more loop stuff> | else: | completed = False I presume you meant True | if not completed: | <break-only statements> | | It felt icky but we're all still here so it couldn't have been that | bad. tjr -- http://mail.python.org/mailman/listinfo/python-list