Andrew Barnert added the comment: So something like the first version below? Or should even the example be inline, as in the second version below? (Apologies if the formatting gets screwed up pasting from docs to bugs.)
--- Range objects are inappropriate for non-integral types, especially inexact types such as :class:`float`. In most cases, for such types, it is better to specify a count of numbers or intervals instead of a step size. For example: >>> start, stop, num = 0, 10, 11 >>> step = (stop-start)/(num-1) >>> [start + i*step for i in range(num)] [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] .. seealso:: * `linspace recipe <http://code.activestate.com/recipes/579000/>`_ for an example lazy sequence built on this algorithm, and links to alternatives. --- Range objects are inappropriate for non-integral types, especially inexact types such as :class:`float`. In most cases, it is better to specify a count of numbers or intervals instead of a step size, as in `[start + i*(stop-start)/(num-1) for i in range(num)]`. .. seealso:: * `linspace recipe <http://code.activestate.com/recipes/579000/>`_ for an example lazy sequence built on this algorithm, and links to alternatives. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23226> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com