Skip to content

Instantly share code, notes, and snippets.

@kissgyorgy
Created February 1, 2017 00:04
Show Gist options
  • Save kissgyorgy/92e477507ebfd126d90ee38438e3550a to your computer and use it in GitHub Desktop.
Save kissgyorgy/92e477507ebfd126d90ee38438e3550a to your computer and use it in GitHub Desktop.
Python: hack instead of nonlocal keyword in Python2
def fibonacci():
a, b = [1], [0]
def fibo():
a[0], b[0] = b[0], a[0] + b[0]
return a[0]
return fibo
fib = fibonacci()
for _ in range(10):
print fib(),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment