Skip to content

Instantly share code, notes, and snippets.

@varepsilon
Last active October 2, 2015 21:38
Show Gist options
  • Save varepsilon/2326473 to your computer and use it in GitHub Desktop.
Save varepsilon/2326473 to your computer and use it in GitHub Desktop.
Emulate dict comprehensions
# 1
dict([(x, x**2) for x in range(N)])
# 2
dict({(x, x**2) for x in range(N)})
# 3
dict((x, x**2) for x in range(N))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment