Andy Cheesman wrote:

> After watching a nice Google video on Python 3K, and seeing the 
> forthcoming removal of range, I've looked at substitution range with 
> xrange within my code. Direct substitution works for 90% percent of the 
> case (i.e.   for thing in xrange(number):  ), however i can't change the 
> example below where I need a non-continuous range. Any suggestions?
> 
> Andy
> 
> x = range(10)  + range(20, 30)

x = list(range(10)) + list(range(20, 30))

or

from itertools import chain
for thing in chain(range(10), range(20, 30)):

which avoids creating the intermediate lists.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to