PEP for fp.type()

Andrew Dalke dalke at
Tue Jan 15 23:43:28 EST 2002

Tim Cera wrote:
>"Skip Montanaro" <skip at> wrote
>> I see nothing wrong with a module like  I don't understand why
>> this is best as a file method.  Your message didn't provide any
>Your right, I didn't give a rational, just described the idea.
>I can think of four reasons...

The first two are reasons to have it as a standard module.  The aren't
reasons for file objects to grow a "magic" method.

>Heck, maybe just extend to
>support the mimetypes approach, but replace imghdr, sndhdr, and

In other words, that.  The more functionality that's put into
a standard object, the harder it is to emulate (as in, make a file-like
object).  For example, should that method be usable on a socket,
which acts like a file handle?  Or on a StringIO?

It's easier to have a module then pass it the filehandle or filename.

BTW, I've never needed /etc/magic for anything I've done.  The file
typing I need can't be done with that limited of a language.

                    dalke at

More information about the Python-list mailing list