Created
September 28, 2016 12:21
-
-
Save avalanchy/edd5e93a6b0e72f69a929ef0588c48be to your computer and use it in GitHub Desktop.
covert all dict keys to uppercase in python.
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 _uppercase_for_dict_keys(lower_dict): | |
upper_dict = {} | |
for k, v in lower_dict.items(): | |
if isinstance(v, dict): | |
v = _uppercase_for_dict_keys(v) | |
upper_dict[k.upper()] = v | |
return upper_dict |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!