guessing file type

Ben Finney ben+python at benfinney.id.au
Fri Jul 17 08:28:41 EDT 2009


Seldon <seldon at katamail.it> 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:http://pypi.python.org/pypi/python-magic> 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