Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
class UnknownValueDefaultsToKey(dict):
def __getitem__(self, key):
return self.get(key, key)
foox = UnknownValueDefaultsToKey({
'a': 100,
'b': 200,
'c': 300,
})
print foox['a']
print foox['q']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment