title: How to pass command line arguments to a python file from a script
body: <p>I have a file 'train.py' which takes command line arguments to run. Some arguments are necessary and some are optional</p>
  
  <p>For Example. </p>
  
  <pre><code>.\train.py --counter arg1 --opt optional_arg
  </code></pre>
  
  <p>Now, I would like to write a new file called 'script.py' which will import this 'train.py' and pass the argumets in that script and execute 'train.py' in 'script.py'</p>
  
  <p>I need to do this as I want to give different set of arguments each time to train.py.</p>
  
  <p>I know we can do this using a shell script. I am curious about how to do it using a python script.</p>
  
  <p><strong>train.py</strong></p>
  
  <pre><code>import optparse
  optparser = optparse.OptionParser()
  
  optparser.add_option(
      "--counter", default = "",
      help = "Counter value"
  )
  
  optparser.add_option(
      "--opt", default = "",
      help = "Optinal parameter"
  )
  
  '''Do Something'''
  </code></pre>
  
  <p><strong>script.py</strong></p>
  
  <pre><code>args = {
      '--counter':''
      '--opts':''
  }
  
  lst = [ 1, 2, 3]
  
  for counter in lst:
      '''set command line arguments here in args dictionary'''
      args['--counter'] = counter
  
      '''run train.py with args as input dictionary'''
  </code></pre>