Skip to content

Instantly share code, notes, and snippets.

@dfm
Created November 20, 2012 22:45
Show Gist options
  • Select an option

  • Save dfm/4121783 to your computer and use it in GitHub Desktop.

Select an option

Save dfm/4121783 to your computer and use it in GitHub Desktop.
y u suck so much?
fs = []
for i in range(10):
fs.append(lambda: i)
print [f() for f in fs]
fs = []
for i in range(10):
def f(j):
return lambda: j
fs.append(f(i))
print [f() for f in fs]
@ghl3

ghl3 commented Nov 21, 2012

Copy link
Copy Markdown

This stuff is always a pain. Your solution is nice, though.

@sjoertvv

sjoertvv commented Dec 3, 2012

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment