Skip to content

Instantly share code, notes, and snippets.

@rainbowbird
Created February 22, 2020 13:11
Show Gist options
  • Save rainbowbird/2493b0d7f699085c699bb9332838fff7 to your computer and use it in GitHub Desktop.
Save rainbowbird/2493b0d7f699085c699bb9332838fff7 to your computer and use it in GitHub Desktop.
Python closures and "currying"
def outer(out_arg):
def inner(inner_arg):
return inner_arg + outer_arg
return inner
func = outer(10)
func(5)
func.__closure__
func.__closure__[0]
func.__closure__[0].cell_contents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment