Skip to content

Instantly share code, notes, and snippets.

@fonnesbeck
Created July 12, 2011 21:46
Show Gist options
  • Save fonnesbeck/1079055 to your computer and use it in GitHub Desktop.
Save fonnesbeck/1079055 to your computer and use it in GitHub Desktop.
Wrapping a class in an iterator
class AlwaysFive:
def __iter__(self):
while True:
yield 5
a = AlwaysFive()
it = iter(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment