Skip to content

Instantly share code, notes, and snippets.

@dpritchett
Created January 15, 2012 19:17
Show Gist options
  • Save dpritchett/1616892 to your computer and use it in GitHub Desktop.
Save dpritchett/1616892 to your computer and use it in GitHub Desktop.
def pearl_jam():
n = 1
while n < 10:
yield n
n += 1
n = pearl_jam()
n.next()
# OUT: 1
n.next()
# OUT: 2
n.next()
# OUT: 3
n.next()
# OUT: 4
n.next()
# OUT: 5
n.next()
# OUT: 6
n.next()
# OUT: 7
n.next()
# OUT: 8
n.next()
# OUT: 9
n.next()
# OUT: Traceback (most recent call last):
# OUT: File "<input>", line 1, in <module>
# OUT: StopIteration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment