[Tutor] replacing range with xrange
Tim Golden
mail at timgolden.me.uk
Mon Jan 28 14:09:27 CET 2008
Andy Cheesman wrote:
> Hi people,
>
> 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)
>
> for thing in x:
> ...
Define your own top-level range as:
def range (x):
return list (xrange (x))
maybe?
TJG
More information about the Tutor
mailing list