If it helps, there's a builtin module for figuring out mimetypes; http://docs.python.org/lib/module-mimetypes.html >>> import mimetypes >>> mimetypes.guess_type('.gif') ('image/gif', None) Cheers, Andy.