python - Range with step of type float -
this question has answer here:
- how use decimal range() step value? 26 answers
the documentation says range
must behave implementation (for positive step
):
def range(start, stop, step): x = start while true: if x >= stop: return yield x x += step
it says arguments must integers. why that? isn't definition valid if step float?
in case, esp. needing range
function accepts float type step
argument. there in python or need implement own?
more specific: how translate c code directly python in nice way (i.e. not doing via while
-loop manually):
for(float x = 0; x < 10; x += 0.5f) { /* ... */ }
you use numpy.arange
.
edit: docs prefer numpy.linspace
. thanks @droogans noticing =)
Comments
Post a Comment