Skip to content

Instantly share code, notes, and snippets.

@TimFletcher
Created May 26, 2012 02:53
Show Gist options
  • Save TimFletcher/2791847 to your computer and use it in GitHub Desktop.
Save TimFletcher/2791847 to your computer and use it in GitHub Desktop.
Lists vs Generators
# Using lists
def allcombinations(starters, endings):
result = []
for s in starters:
for e in endings:
result.append(s+e)
return result
# Using a generator
def allcombinations(starters, endings):
for s in starters:
for e in endings:
yield s+e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment