title: How to check type of files without extensions?
body: <p>I have a folder full of files and they don't have an extension. How can I check file types? I want to check the file type and change the filename accordingly. Let's assume a function <code>filetype(x)</code> returns a file type like <code>png</code>. I want to do this:</p>
  
  <pre><code>files = os.listdir(".")
  for f in files:
      os.rename(f, f+filetype(f))
  </code></pre>
  
  <p>How do I do this?</p>