Skip to content

Instantly share code, notes, and snippets.

@mdippery
Created August 26, 2014 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdippery/27a4b1bb9aa12e580c37 to your computer and use it in GitHub Desktop.
Save mdippery/27a4b1bb9aa12e580c37 to your computer and use it in GitHub Desktop.
Python's scopes are weird
# This totally works, even though `i` isn't passed into the
# lambda, nor is it defined prior to the lambda declaration.
calculate_efp = lambda v: v - i
[calculate_efp(v) for i, v in enumerate([10,100,1000])]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment