title: Python2: what do str.encode() and unicode.decode() do?
body: <p>From this question and its answers <a href="https://stackoverflow.com/questions/18034272/python-str-vs-unicode-types">Python str vs unicode types</a> I understood that <code>unicode.encode()</code> gives you <code>str</code> and <code>str.decode()</code> gives you <code>unicode</code>:</p>
  
  <pre><code>a = 'à'
  ua = u'à'
  print type(a)  # str
  print type(ua)  # unicode
  print ua.encode('utf-8') == a  # True
  print a.decode('utf-8') == ua  # True
  </code></pre>
  
  <p>But I don't understand the purpose of <code>unicode.decode()</code> and <code>str.encode()</code> methods. What are they supposed to return? How can I use them? Both following lines are failing with <code>UnicodeDecodeError</code> or <code>UnicodeEncodeError</code>:</p>
  
  <pre><code>print ua.decode('utf-8')
  print a.encode('utf-8')
  </code></pre>