Feb-21-2018, 11:44 AM
Hi, I'm trying to use argparse to handle a single command line option, this is the code that I wrote:
#!/usr/bin/env python3 import argparse parser = argparse.ArgumentParser(description='foo') parser.add_argument("Option", choices=['true','false'] ) args = parser.parse_args() if (args.Option == 'true'): print('something') else: #then it's false print('something else')I'd like to know if it's correct or there's a better way to do this