frange 1 >>> import itertools 2 >>> def frange(start, end=None, inc=1.0): 3 if end is None: 4 end = start + 0.0 5 start = 0.0 6 assert inc 7 for i in itertools.count(): 8 next = start + i * inc 9 if(inc>0.0 and next >= end) or (inc<0.0 and next <= end):10 break11 yield next12
1 >>> for j in frange( 1.0 , 5.0 , 0.5 ): 2 print (j)
Outputs:
1.0
1.52.02.53.03.54.04.5