On Fri, Sep 23, 2011 at 7:13 PM, Steven D'Aprano <st...@pearwood.info> wrote: >>> http://code.activestate.com/recipes/577068-floating-point-range/ >> >> I notice that your examples carefully skirt around the rounding issues. > > I also carefully *didn't* claim that it made rounding issues disappear > completely. I'll add a note clarifying that rounding still occurs and as a > consequence results can be unexpected.
I believe this API is fundamentally wrong for float ranges, even if it's great for int ranges, and I will fight against adding it to the stdlib in that form. Maybe we can come up with a better API, and e.g. specify begin and end points and the number of subdivisions? E.g. frange(0.0, 2.1, 3) would generate [0.0, 0.7, 1.4]. Or maybe it would even be better to use inclusive end points? OTOH if you consider extending the API to complex numbers, it might be better to specify an initial value, a step, and a count. So frange(0.0, 0.7, 3) to generate [0.0, 0.7, 1.4]. Probably it shouldn't be called frange then. -- --Guido van Rossum (python.org/~guido) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com