[Python-Dev] Python 2.4 | 7.3 The for statement

Nick Coghlan ncoghlan at iinet.net.au
Sun Mar 20 03:46:32 CET 2005


Juan Carlos Rodrigo Garcia wrote:
> It is easier if we see it beforehand:
> -------------------------------------
>  
> leave = False
> alist = [1,2,3,3,4,5,6,7,8,9]
> for item in alist and not leave:
>  if item is 1: leave = True

Interesting idea, but not really needed given the existence of the break statement:

for item in alist:
   if item is 1:
     break

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net


More information about the Python-Dev mailing list