title: How do I add basic authentication to a Python REST request?
body: <p>I have the following simple Python code that makes a simple post request to a REST service -</p>
  
  <pre><code>params= { "param1" : param1,
            "param2" : param2,
            "param3" : param3 }
  xmlResults = urllib.urlopen(MY_APP_PATH, urllib.urlencode(params)).read()
  results = MyResponseParser.parse(xmlResults)
  </code></pre>
  
  <p>The problem is that the url used to call the REST service will now require basic authentication (username and password). How can I incorporate a username and password / basic authentication into this code, as simply as possible?</p>