[issue41719] Why does not range() support decimals?

2020-09-11 Thread chen-y0y0
Change by chen-y0y0 : -- resolution: -> not a bug stage: needs patch -> resolved status: open -> closed ___ Python tracker ___ ___

[issue41719] Why does not range() support decimals?

2020-09-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, the usual approach to the OP's problem is: >>> [x*0.5 for x in range(10)] [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5] This technique generalizes to other sequences as well: >>> [x**2 for x in range(10)] [0, 1, 4, 9, 16, 25,

[issue41719] Why does not range() support decimals?

2020-09-04 Thread Steven D'Aprano
Steven D'Aprano added the comment: Generating a range of equally-spaced floats is tricky and the range builtin is not the right solution for this. For numerical work, we often need to specify the number of steps, not the step size. For instance, in numeric integration, we often like to

[issue41719] Why does not range() support decimals?

2020-09-04 Thread Terry J. Reedy
Terry J. Reedy added the comment: The original title was "Why does not range() support decimals?". In general, such questions should be directed to question forums, such as https://mail.python.org/mailman/listinfo/python-list or stackoverflow.com. This question has been answered on both,

[issue41719] Why does not range() support decimals?

2020-09-04 Thread chen-y0y0
New submission from chen-y0y0 : # I try: >>> range(0,5,0.5) # I hope it will (0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5). But... Traceback (most recent call last): File "", line 1, in range(0,5,0.5) TypeError: 'float' object cannot be interpreted as an integer -- components: