Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save theparadoxer02/f3e6a748a2f10868c14fcf38631c5174 to your computer and use it in GitHub Desktop.
Save theparadoxer02/f3e6a748a2f10868c14fcf38631c5174 to your computer and use it in GitHub Desktop.
Iteratos vs Generatos
#!/user/bin/python
def custom_generator(x):
for i in range(10):
if i == 5:
return
else:
yield i
# fun.py
def fibonacci(max):
result = 0
base = 1
while result <= max:
# This yield statement is where the execution leaves the function.
yield result
# This is where the execution comes back into the function. This is
# just whitespace, but that it came back while preserving the state
# of the function is pretty awesome.
print("here ")
# Fibonacci code to increase the number according to
# https://en.wikipedia.org/wiki/Fibonacci_number
n = result + base
result = base
base = n
def simpleGeneratorFun():
pre1 = 1
pre2 = 1
sumValue = 1
yield sumValue
print('First stop')
for i in range(0, 5):
print('Secode Stop')
yield sumValue
import pdb
pdb.set_trace()
sumValue = pre1 + pre2
pre1 = pre2
pre2 = sumValue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment