guessing file type

Ben Finney ben+python at
Fri Jul 17 08:28:41 EDT 2009

Seldon <seldon at> writes:

> Hello,  I need to determine programmatically a file type from its
> content/extension (much like the "file" UNIX command line utility)

The Unix ‘file(1)’ program does its magic with a library called “magic”
and a corresponding database.

> I searched for a suitable Python library module, with little luck. Do
> you know something useful ?

This package <URL:> provides
Python bindings to libmagic.

 \     “Unix is an operating system, OS/2 is half an operating system, |
  `\    Windows is a shell, and DOS is a boot partition virus.” —Peter |
_o__)                                                        H. Coffin |
Ben Finney

More information about the Python-list mailing list