[issue40841] Provide mimetypes.sniff API as stdlib

Serhiy Storchaka report at bugs.python.org
Tue Jul 28 03:07:29 EDT 2020


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

I think that both functions for detecting file type, by name and by content, are useful in different circumstances. We have similar more specific detection functions sndhdr and imghdr.

But I am not sure whether it should be a part of the mimetypes module or separate module. Should it use sndhdr and imghdr modules for audio and image types? Should it be a wrapper to the libmagic library (https://linux.die.net/man/3/libmagic) or reimplement it in Python?

If we add the code for detecting the file type based on algorithms used in browsers, should not we add also the code for detecting the text encoding based on other algorithms used in browsers, or it is too much?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40841>
_______________________________________


More information about the Python-bugs-list mailing list