Skip to content

Instantly share code, notes, and snippets.

@brentshermana
Created March 2, 2018 21:30
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 brentshermana/16fff59d666250e0222a37efb9df0622 to your computer and use it in GitHub Desktop.
Save brentshermana/16fff59d666250e0222a37efb9df0622 to your computer and use it in GitHub Desktop.
Python generator based iterator
class X:
def __init__(self, l):
self.l = l
def __iter__(self):
for x in self.l:
yield x
x = X([1,2,3])
for i in x:
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment