Breaking Out

Carl Banks imbosol at vt.edu
Wed Aug 28 03:31:16 CEST 2002


Bradley D. Larson wrote:
> I believe a cleaner method is:
> 
> while x = y:
>    blah
>    blah
>    blah
>    if break_now:
>        break
>    blah
>    blah
>    blah
>    if break_now:
>        break
>    blah
>    blah
>    blah
> [...]
>    break    # dont forget the last break!


How about:

for i in range(x==y):
    blah
    blah
    blah
    if break_now:
        break
    blah
    blah
    blah
    if break_now:
        break
    blah
    blah
    blah
    # no need for a last break!


Probably too cute, though.

-- 
CARL BANKS
http://www.aerojockey.com



More information about the Python-list mailing list