Skip to content

Instantly share code, notes, and snippets.

@drobati
Created February 22, 2016 15:56
Show Gist options
  • Save drobati/00ffe2500550a0a0bf31 to your computer and use it in GitHub Desktop.
Save drobati/00ffe2500550a0a0bf31 to your computer and use it in GitHub Desktop.
Return list until match is found
list(gen)
# ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
items = list()
try:
while gen:
item = next(gen)
items.append(item)
if item == '4': break
except StopIteration:
print "log a message"
pass
@drobati
Copy link
Author

drobati commented Feb 22, 2016

Thanks @GrappigPanda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment