multiple ranges to for statement?

Greg Ewing greg at cosc.canterbury.ac.nz
Wed Apr 10 02:37:45 EDT 2002


Ian Bicking wrote:
> 
> for i in range(a, b) + range(c, d):
>     ...

Alternatively:

  for seq in range(a, b), range(c, d):
    for i in seq:
      ...

which avoids building two copies of the
sequences.

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list