title: How to check if variable is string with python 2 and 3 compatibility
body: <p>I'm aware that I can use: <code>isinstance(x, str)</code> in python-3.x but I need to check if something is a string in python-2.x as well. Will <code>isinstance(x, str)</code> work as expected in python-2.x? Or will I need to check the version and use <code>isinstance(x, basestr)</code>?</p>
  
  <p>Specifically, in python-2.x:</p>
  
  <pre><code>&gt;&gt;&gt;isinstance(u"test", str)
  False
  </code></pre>
  
  <p>and python-3.x does not have <code>u"foo"</code></p>