title: Way to make terminal calls in Python, capture what is returned?
body: <p>I'm working on a project right now where I'm passing in strings into this NLP API, which returns JSON objects of the string's sentiment analysis.  I will admit I am a Python newbie: </p>
  
  <p><a href="http://text-processing.com/docs/sentiment.html" rel="nofollow noreferrer">http://text-processing.com/docs/sentiment.html</a></p>
  
  <p>The documentation for calling the API is simple through a command line.  It works fine when I open up terminal and run the command.</p>
  
  <pre><code>curl -d "text=great" http://text-processing.com/api/sentiment/
  </code></pre>
  
  <p>Running that command on terminal produces:</p>
  
  <pre><code>{"probability": {"neg": 0.59309571705919506, "neutral": 0.5403849950008478, "pos": 0.40690428294080488}, "label": "neutral"}
  </code></pre>
  
  <p>I am trying to figure out a way in Python to make a terminal call using the same command, and capturing the JSON object, decoding it, and using it in my code.</p>
  
  <p>So far, I've found that using the below code works in Python:</p>
  
  <pre><code>import os
  os.system('curl -d "text=great" http://text-processing.com/api/sentiment/')
  </code></pre>
  
  <p>However, when I run this line in my Python file, it prints out the JSON object.  How can I save the output to a variable, and then dump string and use the JSON result in my code?  </p>
  
  <p>When I try:</p>
  
  <pre><code>import os
  sentiment = os.system('curl -d "text=great" http://text-processing.com/api/sentiment/')
  </code></pre>
  
  <p>It ignores my variable assignment, and proceeds to print out the JSON object.</p>
  
  <p>Any suggestions?</p>