PEP for fp.type()

Andrew Dalke dalke at dalkescientific.com
Wed Jan 16 05:43:28 CET 2002


Tim Cera wrote:
>"Skip Montanaro" <skip at pobox.com> wrote
>> I see nothing wrong with a module like magic.py.  I don't understand why
>> this is best as a file method.  Your message didn't provide any
motivation.
>
>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 magic.py to
>support the mimetypes approach, but replace imghdr, sndhdr, and
>mimetypes.

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.

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list