Skip to content

Instantly share code, notes, and snippets.

@jaychoo
Created October 18, 2011 13:29
Show Gist options
  • Save jaychoo/1295421 to your computer and use it in GitHub Desktop.
Save jaychoo/1295421 to your computer and use it in GitHub Desktop.
Python dict key - pop/get
d = {1:1, 2:2}
a = d.pop(1, None) # Pop item from d
b = d.get(2, None) # Get item from d, no change in the dict object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment