Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
https://repl.it/C6f4/1 created by charles2588
#Generator function yields iterator rather than returning value, no function calls or calls on stack thus saving memory
def f(n):
for x in range(n):
yield x**3
for i in f(5):
print(i)
Python 3.5.1 (default, Dec 2015, 13:05:11)
[GCC 4.8.2] on linux
0
1
8
27
64
=> None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.