import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-y', '--y-option', action='store_true')
args = parser.parse_args()
y_option = "enable_y" if args.y_option else ''
print(y_option)
if -y or --y-option is passed in, I want to set variable y_option to enable_y else an empty string, I believe this should be possible with argparse so the y_option = ... line is not needed? I couldn't figure it out. I cannot use default as it will set default value even if -y is not passed in.