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
| package main | |
| import ( | |
| "bytes" | |
| "flag" | |
| "fmt" | |
| "log" | |
| "os" | |
| "regexp" | |
| "strconv" |
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
| # given an array keys and a dictionary, recursively navigate down the dictionary to fetch value | |
| def _get_value(dict, keys=[], default=None): | |
| """ | |
| _get_value({"k":{"k1":"v1"}}, ["k", "k1"]) == "v1" | |
| """ | |
| if not keys: | |
| return default | |
| elif len(keys) == 1: | |
| return dict.get(keys[0], default) | |
| else: |