Last active
March 28, 2017 14:27
-
-
Save johnscillieri/13e8312cc1e769a81c9bbae35c6983d4 to your computer and use it in GitHub Desktop.
Convert docopt dictionary args to a namedtuple
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
def convert_args(dictionary): | |
''' Convert a docopt dict to a namedtuple ''' | |
new_dict = { key = key.replace("--", "").replace("-", "_").lower() | |
for key, value in dictionary.items() } | |
return namedtuple('DocoptArgs', new_dict.keys())(**new_dict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment