Skip to content

Instantly share code, notes, and snippets.

@holys
Created December 3, 2013 11:40
Show Gist options
  • Save holys/7767808 to your computer and use it in GitHub Desktop.
Save holys/7767808 to your computer and use it in GitHub Desktop.
# coding: utf-8
class MyIterator(object):
def __init__(self, step):
self.step = step
def next(self):
if self.step == 0:
raise StopIteration
self.step -= 1
return self.step
def __iter__(self):
return self
if __name__ == '__main__':
for i in MyIterator(10):
print i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment