Skip to content

Instantly share code, notes, and snippets.

@cvno
Last active October 30, 2017 02:42
Show Gist options
  • Save cvno/65e6ff8a64212f1841bb44dd6c7f080a to your computer and use it in GitHub Desktop.
Save cvno/65e6ff8a64212f1841bb44dd6c7f080a to your computer and use it in GitHub Desktop.
class Range:
def __init__(self,stop,start=0):
self.start=start
self.stop=stop
def __iter__(self):
return self
def __next__(self):
if self.start > self.stop-1:
raise StopIteration
n=self.start
self.start+=1
return n
r=Range(10)
for i in r:
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment