On Sun, Dec 1, 2013 at 7:14 PM, Dominik George <n...@naturalnet.de> wrote:
> Hi,
>
>> - Do not create a list of the floating point values as i=[0.01, 0.02,
>> 0.03..] - either like that or by using a suitable mathematical formula
>> combined with a list comprehension
>
> You could simply write your own version of xrange that does it, as a
> generator:
>
>   def xrange_f(start, stop, step):
>       x = start
>       while x < stop:
>           yield x
>           x += step
>
> Then, in your code, you can do:
>
>   for f in xrange_f(0, 10, 0.01):
>       pass

Thanks Dominik. Yes, this is a good abstraction if I need this
functionality at multiple places.

Best,
Amit.


-- 
http://echorand.me
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to