Skip to content

Instantly share code, notes, and snippets.

@xmeng1
Created Sep 18, 2019
Embed
What would you like to do?
parser.py
from __future__ import print_function
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--color', help='The name of the color')
parser.add_argument('--verbose', help='Print more data',
action='store_true')
parser.add_argument('--cuda', '-c', default=True, action='store_false')
args = parser.parse_args()
def main():
global args
args = parser.parse_args()
print(args.color)
print(args.verbose)
print(args.cuda)
if args.cuda:
print("xxx")
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment