title: Conditional arguments in Python function call
body: <p>Is there a way pass arguments conditionally in Python (I use Python 2.7)?</p>
  
  <p>As an example, this code gives 2 or 3 arguments depending if the 3rd argument exists in a dictionary.</p>
  
  <pre><code>if "arg3" in my_dict:
      my_method(
          my_dict[arg1],
          my_dict[arg2],
          my_dict[arg3],
      )
  else:
      my_method(
          my_dict[arg1],
          my_dict[arg2],
      )
  </code></pre>
  
  <p>I think it looks redundant to write it this way. I've seen some info on <code>argparse</code>, which I think would look like this:</p>
  
  <pre><code>import argparse
  
  parser = argparse.ArgumentParser()
  parser.add_argument(my_dict[arg1])
  parser.add_argument(my_dict[arg2])
  if arg3 in my_dict:
      parser.add_argument(my_dict[arg3])
  args = parser.parse_args()
  
  my_method(args)
  </code></pre>
  
  <p>I don't really like this method either, as it needs an import and is hard to read.</p>
  
  <p>Is there a way to do something like:</p>
  
  <pre><code>my_method(
      my_dict[arg1],
      my_dict[arg2],
      my_dict[arg3] if arg3 in my_dict,
  )
  </code></pre>
  
  <p>Or any other way I am missing, that would be simple and clean?</p>