title: What are the differences between type() and isinstance()?
body: <p>What are the differences between these two code snippets?</p>
  <p>Using <a href="https://docs.python.org/3/library/functions.html#type" rel="noreferrer"><code>type</code></a>:</p>
  <pre><code>import types
  
  if type(a) is types.DictType:
      do_something()
  if type(b) in types.StringTypes:
      do_something_else()
  </code></pre>
  <p>Using <a href="https://docs.python.org/3/library/functions.html#isinstance" rel="noreferrer"><code>isinstance</code></a>:</p>
  <pre><code>if isinstance(a, dict):
      do_something()
  if isinstance(b, str) or isinstance(b, unicode):
      do_something_else()
  </code></pre>