Category : argparse

My python code is: # my_script.py import argparse parser = argparse.ArgumentParser() parser.add_argument("-v", "–verbose", help="increase output verbosity", action="store_true") args = parser.parse_args() if args.verbose: print("verbosity turned on") My default python is Python 3.7.4 (also python 2 is installed on my PC). When I run this script from Windows command line this way: py -2 my_script.py or this ..

Read more

parser = argparse.ArgumentParser() parser.add_argument("-f","–first", action="store_true", default=False, help = "Execute first option") parser.add_argument("-s","–second", action="store_true",default=False, help = "Execute second option") parser.add_argument("-t","–third", action="store_true", default=False, help = "Execute third option") args = parser.parse_args() if args.first: print("i am the 1st option") elif args.second: print("i am the 2nd option") elif args.third: print("i am the last option") I am trying to open ..

Read more