[EMAIL PROTECTED] wrote:
> Are there other good ways for this simple problem? Generators?

Very interesting problem :) That never occured to me.

To prevent python from loading that entire list into memory, one
could, as you suggested, use a generator:

>>> def genrange( start , stop , step = 1 ):
        while start < stop:
                yield start
                start += step
                
>>> for x in range( 5 ):
        print "%s " % str( x ),

0  1  2  3  4 

>>> for x in genrange( 0 , 5 ):
        print "%s " % str( x ),
        
0  1  2  3  4 

-- 
Daniel Bickett
dbickett at gmail.com
http://heureusement.org/
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to