Created
August 15, 2018 05:05
-
-
Save wizpig64/2dedee3bf9d13caff5c98b642df6339a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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