title: Detect if a variable is a datetime object
body: <p>I have a variable and I need to know if it is a datetime object.</p>
  
  <p>So far I have been using the following hack in the function to detect datetime object:</p>
  
  <pre><code>if 'datetime.datetime' in str(type(variable)):
       print('yes')
  </code></pre>
  
  <p>But there really should be a way to detect what type of object something is. Just like I can do:</p>
  
  <pre><code>if type(variable) is str: print 'yes'
  </code></pre>
  
  <p>Is there a way to do this other than the hack of turning the name of the object type into a string and seeing if the string contains <code>'datetime.datetime'</code>?</p>