Last active
August 29, 2015 14:26
-
-
Save tierpod/e6d651a0b7d1ae45a6a3 to your computer and use it in GitHub Desktop.
python docopt arguments normalize: lowercase, remove '-'
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
''' | |
args: {'--append': True, 'FILE1': 'test', 'normal': 'normal'} | |
cfg: {'append': True, 'file1': 'test', 'normal': 'normal'} | |
''' | |
# simple way | |
cfg = {} | |
for arg in args: | |
cfg[arg.lower().replace('-','')] = args[arg] | |
# list comprehension way | |
cfg = {k.lower().replace('-',''): v for (k, v) in args.iteritems()} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment