Because range is used for indexing and if you need to address an element in a sequence, you need integers.
But you've all tools to build your own range:
def arange(start_or_end, end=None, step=1):
if end is None:
start_or_end, end = 0, start_or_end
value = start_or_end
while value < end:
yield value
value += step
Testing with Decimal:
from decimal import Decimal
for dec in arange(Decimal(0), Decimal(5), Decimal("0.25")):
print(dec)
Output:
0
0.25
0.50
0.75
1.00
1.25
1.50
1.75
2.00
2.25
2.50
2.75
3.00
3.25
3.50
3.75
4.00
4.25
4.50
4.75
Testing with Fraction:
from fractions import Fraction
for frac in arange(Fraction(0), Fraction(5), Fraction(1, 3)):
print(frac)
Output:
0
1/3
2/3
1
4/3
5/3
2
7/3
8/3
3
10/3
11/3
4
13/3
14/3
Testing with float:
from decimal import Decimal
for real in arange(0, 5, 0.25):
print(real)
Output:
0
0.25
0.5
0.75
1.0
1.25
1.5
1.75
2.0
2.25
2.5
2.75
3.0
3.25
3.5
3.75
4.0
4.25
4.5
4.75