Skip to content

Instantly share code, notes, and snippets.

@thecraftman
Created July 2, 2021 11:56
Show Gist options
  • Save thecraftman/f645f28dc9819595aa108ab9b32a05bf to your computer and use it in GitHub Desktop.
Save thecraftman/f645f28dc9819595aa108ab9b32a05bf to your computer and use it in GitHub Desktop.
Python Generators from a list comprehension.
# list comprehension
my_nums = (x*x for x in [1, 2, 3, 4, 5])
print my_nums
for num in my_nums:
print num
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment