Pythonically-expressed nested-loop break?

Delaney, Timothy tdelaney at avaya.com
Mon Jan 14 16:54:57 EST 2002


> From: bokr at oz.net [mailto:bokr at oz.net]
> 
> def btest():
>     while 1:
>         print 'While1'
>         while 2:
>             print tab,'While2'
>             while 3:
>                 print tab*2,'While3'
>                 for i in range(30):
>                      r = randint(0,6)
>                      print tab*3,'r=',r
>                      if r == 1:   break
>     :
>                      elif r == 2: break
>         :
>                      elif r == 3: break
>             :
>             print tab*2,Break3
>         print tab,Break2
>     print Break1
> 
> for test in (1,2,3):
>     print 'test',test
>     btest()

I'm not intending to be insulting, but I ignored this suggestion when it
first came up in the hopes that it would just quietly disappear.

One of the big wins with Python is the lack of block delimiters. This is
essentially creating block delimiters, but worse - they are optional and
only used for some blocks. This is a Bad Thing(TM).

Additionally IM(NS)HO, it is incredibly ugly. I mean *really* *really* ugly.
It's kind of like comparing it to space. Space is big ... (see HHGTTG for
the rest).

Tim Delaney




More information about the Python-list mailing list