guessing file type

VanL van.lindberg at gmail.com
Fri Jul 17 08:39:22 EDT 2009


Seldon wrote:
> Hello,  I need to determine programmatically a file type from its 
> content/extension (much like the "file" UNIX command line utility)
> 
> I searched for a suitable Python library module, with little luck. Do 
> you know something useful ?

Python-magic (http://pypi.python.org/pypi/python-magic/0.1) wraps 
libmagic -- the same thing that "file" uses -- but getting it on windows 
is a pain. I have never been able to do it, anyway.

A more cross-platform library with a similar scope is hachoir. Still 
seems to be available from PyPI, but the website seems to have fallen 
off the 'net.




More information about the Python-list mailing list