title: How to use "argparse" argument across python files?
body: <p>Let's say I have a main.py and a subfile.py.</p>
  <ol>
  <li>main.py</li>
  </ol>
  <pre><code>import subfile #Writen by myself. I want to share argparse with it
  
  import argparse
  parser = argparse.ArgumentParser(description='test',formatter_class=argparse.ArgumentDefaultsHelpFormatter)
  parser.add_argument('--a', type=int, default=0, help='test')
  args = parser.parse_args()
  
  args.a=0
  subfile.fun()
  
  args.a=1
  subfile.fun()
  
  args.a=0
  subfile.fun()
  </code></pre>
  <p>2.subfile.py</p>
  <pre><code>xxxxxsome operation here to use args in main.pyxxxx
  # In tensorflow wrapped argparse, I just need to define the same ArgumentParser to use args defined in main.py. 
  # But it's not suitable for &quot;argparse&quot;, which would cause conflicts.
  
  def fun():
      if args.a==0:
          print('yes')
      else:
          print('no')
  
  </code></pre>
  <p>In main.py I use argparse to pass arguments, and main.py use subfile.py.</p>
  <p>Now, I want to use args define in main.py, how can I do?</p>
  <p>(The codes are an simplified example described the problem, which can't be solved by reorganized code and has to be solved by using args in subfile.py. )</p>
  <p>Thanks for your help! I have been torture by some bugs for the whole day and your answer would help me out. Appreciated!</p>
  <hr />
  <p>edit:
  Actually I know how to pass a paramter to a funciton. But as I said above, I writed the example code just for the key solution: is how to use <strong>the library &quot;argparse&quot;</strong> across python file, which is supported in a similar library in tensorflow &quot;FLAG&quot;.</p>