There are actually different bindings for libmagic. One set is part of the
original distribution. It can be found in /usr/src/contrib/file/python/.
But in my opinion it is somewhat cumbersome to use and not very Pythonic.