Skip to content

Instantly share code, notes, and snippets.

@wizpig64
Created August 15, 2018 05:05
Show Gist options
  • Save wizpig64/2dedee3bf9d13caff5c98b642df6339a to your computer and use it in GitHub Desktop.
Save wizpig64/2dedee3bf9d13caff5c98b642df6339a to your computer and use it in GitHub Desktop.
# assembling a list the old way
def do_stuff(x, y, z):
l = []
l += do_x(x)
l += do_y(y)
l += do_z(z)
return l
# assembling a list with generators (much easier to read!):
def do_stuff(x, y, z):
yield from do_x(x)
yield from do_y(y)
yield from do_z(z)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment