What is xrange?

Billy Mays noway at nohow.com
Fri Jul 29 15:36:10 EDT 2011


Is xrange not a generator?  I know it doesn't return a tuple or list, so 
what exactly is it?  Y doesn't ever complete, but x does.

x = (i for i in range(10))
y = xrange(10)

print "===X==="
while True:
     for i in x:
         print i
         break
     else:
         break

print "===Y==="
while True:
     for i in y:
         print i
         break
     else:
         break



More information about the Python-list mailing list