Skip to content

Instantly share code, notes, and snippets.

@johnscillieri
Last active March 28, 2017 14:27
Show Gist options
  • Save johnscillieri/13e8312cc1e769a81c9bbae35c6983d4 to your computer and use it in GitHub Desktop.
Save johnscillieri/13e8312cc1e769a81c9bbae35c6983d4 to your computer and use it in GitHub Desktop.
Convert docopt dictionary args to a namedtuple
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