title: How can I compare a unicode type to a string in python?
body: <p>I am trying to use a list comprehension that compares string objects, but one of the strings is utf-8, the byproduct of json.loads.  Scenario:</p>
  
  <pre><code>us = u'MyString' # is the utf-8 string
  </code></pre>
  
  <p>Part one of my question, is why does this return False? :</p>
  
  <pre><code>us.encode('utf-8') == "MyString" ## False
  </code></pre>
  
  <p>Part two - how can I compare within a list comprehension?</p>
  
  <pre><code>myComp = [utfString for utfString in jsonLoadsObj
             if utfString.encode('utf-8') == "MyString"] #wrapped to read on S.O.
  </code></pre>
  
  <p>EDIT:  I'm using Google App Engine, which uses Python 2.7</p>
  
  <p>Here's a more complete example of the problem:</p>
  
  <pre><code>#json coming from remote server:
  #response object looks like:  {"number1":"first", "number2":"second"}
  
  data = json.loads(response)
  k = data.keys()
  
  I need something like:
  myList = [item for item in k if item=="number1"]  
  
  #### I thought this would work:
  myList = [item for item in k if item.encode('utf-8')=="number1"]
  </code></pre>