title: Python (3.6.3) argparse: default value of optional parameter to be another parameter's value
body: <p>I have a function that takes as parameters an input folder (required) and output folder (optional), but I want the default value of the (optional) output folder to be the input folder. </p>
  
  <p>I can do this of course using, e.g.</p>
  
  <pre><code>p = argparse.ArgumentParser(description="blah")
  p.add_argument('inpath', type=str, help="Path to input")
  p.add_argument('--outpath', required=False, type=str, help="Path to output")
  
  argin = p.parse_args()
  
  if argin.outpath is None:
      argin.outpath = argin.inpath
  </code></pre>
  
  <p>but I want to set the default value in the definition. In another <a href="https://stackoverflow.com/questions/45686317/python-argparse-set-default-value-of-a-parameter-to-another-parameter">post</a>, the answer is that this is impossible, but i do not trust it, because I have tried </p>
  
  <pre><code>p = argparse.ArgumentParser(description="blah")
  p.add_argument('inpath', type=str, help="Path to input")
  p.add_argument('-o', '--outpath', required=False, type=str, 
                 default=p.parse_args().inpath, help="Path to output")
  </code></pre>
  
  <p>and this works. The only problem is that if I run my function with the <code>-h</code> option, I don't see the <code>--outpath</code> option there; I get</p>
  
  <pre><code>usage: argparse_test.py [-h] inpath
  
  positional arguments:
    inpath      Path to input files.
  
  optional arguments:
    -h, --help  show this help message and exit
  </code></pre>
  
  <p>The same happens, if I make function, say</p>
  
  <pre><code>def assign():
      return p.parse_args().inpath
  </code></pre>
  
  <p>and set the <code>default</code> parameter in the <code>add_argument()</code> method to <code>assign</code>:</p>
  
  <pre><code>p.add_argument('-o', '--outpath', required=False, type=str, default=assign(),
                 help="Path to output")
  </code></pre>
  
  <p>Any ideas?     </p>