Created
October 18, 2011 13:29
-
-
Save jaychoo/1295421 to your computer and use it in GitHub Desktop.
Python dict key - pop/get
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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