title: Having trouble calling to a separate argument parsing function in main()
body: <p>So, I'm trying to develop a script that will allow me to run a command as follows:</p>
  
  <p><code>python3 rhize_refactored.py -l &lt;str&gt;, -sa, -si &lt;int&gt;, -i &lt;input_path&gt;, -o &lt;output_path&gt;</code> </p>
  
  <p>I designed my script such that the argument parsing steps are their own function, and then I call to them in main(). Here's what those sections look like:</p>
  
  <pre><code>from argparse import ArgumentParser
  
  def parse_all_args():
     parser= ArgumentParser()
     parser.add_argument('-sa', '--automation', action='store_true', required=True)
     parser.add_argument('-si', '--sample_id', type=int, required=True)
     parser.add_argument('-i', '--input_path', required=True)
     parser.add_argument('-o', '--output_path', required=True)
     args= parser.parse_args()
     return args.automation, args.sample_id, args.input_path, args.output_path
  
  def parse_language():
     parser = ArgumentParser(prog= 'rhize_refactored.py')
     parser.add_argument('-l', dest='language', choices ['bash','python'], type=str, required=True) 
     args= parser.parse_args()
     return args.language
  
  def r_bash():
     parse_all_args()
     if args.automation:
        stage_automation_templates()
     sample_id= args.sample_id
     s3_input_path= args.input_path
     s3_output_path= args.output_path`
  
  def main():
     parse_language()   
     if args.language == "python":
        r_python() 
     if args.language == "bash":
        r_bash()
  main()
  </code></pre>
  
  <p>When I try to run this script, I get several problems:</p>
  
  <ul>
  <li>It does not let me run the command in one step. I have to run <code>python3 rhize_refactored.py -l</code> first, and then it says I'm missing the <code>-sa, -si, etc...</code> arguments. But when I do all the arguments in one go, it says it doesn't recognize the arguments past <code>-l</code>.</li>
  <li>When I call to the argument parsing functions in main(), it does not recognize 'args', but even if I set <code>args=parse_all_args</code>, it has a problem with the if statements, such as <code>'str' object has no attribute 'automation'</code>.</li>
  </ul>
  
  <p>What can I do to correct these mistakes and any others you foresee?</p>