Last active
August 29, 2015 14:02
-
-
Save heyLu/c50583ca350b9c6a62d2 to your computer and use it in GitHub Desktop.
default dict
This file contains hidden or 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
from collections import defaultdict | |
d = defaultdict(lambda: 42) | |
d["hello"] = "world" | |
d["hello"] # => 'world' | |
d["answer"] # => 42 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment