python - Range with step of type float -


this question has answer here:

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

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -