title: Detect file type from the file contents, not the file name
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/43580/how-to-find-the-mime-type-of-a-file-in-python">How to find the mime type of a file in python?</a>  </p>
  </blockquote>
  
  
  
  <p>I want to detect the type of a file, but I don't want to look at the extension because it may be incorrect. The <code>mimetypes</code> module is filename based. </p>
  
  <p>Is there a standard way to peek inside the file? </p>