title: Pass variable into python script from R using system2()
body: <p>I have seen various versions of this question, but have not been able to figure out how to pass numeric variables into Python from R using system2()</p>
  
  <p>For example suppose I have the following python script as Test.py.</p>
  
  <pre><code>a = 1
  b = 2
  def add(a,b):
      print a + b
  </code></pre>
  
  <p>I can run this in R with</p>
  
  <pre><code>pypath = './Test.py'
  system2('python', args=(sprintf('"%1$s"',pypath)))
  </code></pre>
  
  <p>but what if I wanted to pass the values of a and b in, and have the values returned within R to an R object? Something like, </p>
  
  <pre><code>a = 1
  b = 2
  d = system2('python',args = (sprintf('"%1$s" "%2$s" "%3$s"',pypath,a,b)))
  </code></pre>
  
  <p>I have tried a variety of ways of doing this, but have failed. I know the above is wrong, I just can't figure out how to pass in a and b, much less return a value</p>
  
  <p>My questions are (1) is it possible? and (2) how do you do it?</p>