Skip to content

Instantly share code, notes, and snippets.

@neksa
Created October 2, 2019 22:57
Show Gist options
  • Save neksa/8eb381acee9e5f8983a4b846374c163c to your computer and use it in GitHub Desktop.
Save neksa/8eb381acee9e5f8983a4b846374c163c to your computer and use it in GitHub Desktop.
import argparse
class Test():
def __init__(self):
"""INITIALIZE PARSER"""
parser = argparse.ArgumentParser()
parser.add_argument('--name', type=str, required=False, default='World')
parser.add_argument(
'--testFlag',
help='Will it run?',
action='store_true',
default=False,
required=False)
args = parser.parse_args()
[getattr(self, key)(args) for key, val in vars(args).items() if isinstance(val, bool) and val]
def testFlag(self, args):
print("Hello {}!".format(args.name))
if __name__ == '__main__':
Test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment