Skip to content

Instantly share code, notes, and snippets.

@picanumber
Created March 21, 2016 21:58
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 picanumber/d8638d51ba5eb6eb3bf2 to your computer and use it in GitHub Desktop.
Save picanumber/d8638d51ba5eb6eb3bf2 to your computer and use it in GitHub Desktop.
class CustomRange:
def __init__(self, max):
self.max = max
def __iter__(self):
self.curr = 0
return self
def next(self):
numb = self.curr
if self.curr >= self.max:
raise StopIteration
self.curr += 1
return numb
for i in CustomRange(10):
print i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment