I need to do the following:
ifthere weren't argument's for script variabletest == Falseelifthere was argument-tor--testvariabletest == Trueelsethere were another arguments get them as string and pass to third code
Now I got an error:
# ./cli something
usage: cli [-t]
cli: error: unrecognized arguments: something
My code for first 2 steps:
import argparse
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('-t', '--test', action="store_true")
args = parser.parse_args()
if args.test is True:
intro = None
isinstead of==to test for equality: don't sayif args.test is True:You can just sayif args.test-tin the following case:cli -t first second?firstandsecond?ifconditions aren't clear. Show us several intended usage cases, and what you want theargsnamespace to look like.isfor singletons, like None. Agree with your second statement though.