title: Is there another way to determine a file's mime type by using the magic numbers?
body: <p>I would like to be able to take a file that does not have a file extension and determine what mime type it is by using its magic numbers. Below is the solution using the filetype library solution that works fine. Is there another way to do it?</p>
  <p><a href="https://pypi.org/project/filetype/" rel="nofollow noreferrer">https://pypi.org/project/filetype/</a></p>
  <pre><code>import filetype
  def main():
      kind = filetype.guess('collatz')
      if kind is None:
          print('Cannot guess file type!')
          return
      print('File extension: %s' % kind.extension)
      print('File MIME type: %s' % kind.mime)
      print(kind)
  if __name__ == '__main__':
      main()
  </code></pre>