title: Set value to variable in argparse if option passed in
body: <pre><code>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)
  </code></pre>
  
  <p>if <code>-y</code> or <code>--y-option</code> is passed in, I want to set variable <code>y_option</code> to <code>enable_y</code> else an empty string, I believe this should be possible with argparse so the <code>y_option = ...</code> line is not needed? I couldn't figure it out. I cannot use default as it will set default value even if <code>-y</code> is not passed in.</p>