Created
December 3, 2013 11:40
-
-
Save holys/7767808 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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