Created
October 3, 2015 17:00
-
-
Save trevorhreed/36541fe2f6d019e31dcc to your computer and use it in GitHub Desktop.
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
def get(self, key, fallback): | |
if key == None: | |
return fallback | |
else: | |
node = self.obj | |
keys = key.split('.').reverse() | |
while(len(keys)): | |
k = keys.pop() | |
try: | |
tmp = int(k) | |
k = tmp | |
except ValueError: pass | |
node = node[k] | |
if node == None: | |
return fallback | |
else: | |
return node |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment