Reputation: 667
I want to access and argument from my Python script using argparse:
parser = argparse.ArgumentParser()
# Required positional argument
parser.add_argument('mode', type=str,
help='Operation mode. Either "one" or "two".')
args = parser.parse_args()
print("Argument values:")
print(args.mode)
The variable "args.mode" contains the parameter name plus the value, like this "--mode One". But I want only the value part ("One"). I know I could split up the string but I want to know WHY argparse returns the parameter name. Is there a way to tell it I only want the value?
Upvotes: 0
Views: 400