title: What's the canonical way to check for type in Python?
body: <p>How do I check if an object is of a given type, or if it inherits from a given type?</p>
  <p>How do I check if the object <code>o</code> is of type <code>str</code>?</p>
  <hr />
  <p><sub>Beginners often wrongly expect the string to <em>already be</em> &quot;a number&quot; - either expecting Python 3.x <code>input</code> to convert type, or expecting that a string like <code>'1'</code> is <em>also simultaneously</em> an integer. This is the wrong canonical for those questions. Please carefully read the question and then use <a href="https://stackoverflow.com/questions/354038">How do I check if a string represents a number (float or int)?</a>, <a href="https://stackoverflow.com/questions/20449427/">How can I read inputs as numbers?</a> and/or <a href="https://stackoverflow.com/questions/23294658/">Asking the user for input until they give a valid response</a> as appropriate.</sub></p>