Skip to content

Instantly share code, notes, and snippets.

@JPFrancoia
Created August 3, 2017 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JPFrancoia/b6501ab34a0917384ad24d8018b1ff13 to your computer and use it in GitHub Desktop.
Save JPFrancoia/b6501ab34a0917384ad24d8018b1ff13 to your computer and use it in GitHub Desktop.
Frange: range function with floats increment
def frange(start, end=None, inc=None):
"A range function, that does accept float increments..."
if end == None:
end = start + 0.0
start = 0.0
if inc == None:
inc = 1.0
L = []
while 1:
next = start + len(L) * inc
if inc > 0 and next >= end:
break
elif inc < 0 and next <= end:
break
L.append(next)
return L
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment