[plug] MIME Types by file contents

Craig Ringer craig at postnewspapers.com.au
Fri Jul 2 20:30:45 WST 2004


On Fri, 2004-07-02 at 00:25, Bernd Felsche wrote:

> The list returned by the function contains not only a maintype and
> subtype, but also stuff that might lend itself to smarter encoding
> overall... but I'm not too fussed right now.

I'd like to add a comment on that function: your use of a local variable
called 'file' may bend the brain of some Python users, as 'file' is a
built-in object that's imported into the __main__ namespace from
__builtin__ automatically. Assigning to that name won't affect 'file',
it'll just hide it within that function, but ... it's really weird to
read the code when you're used to writing

fdata = file(path_to_file).read()

and similar.

Also - any chance you can send me some sample output from 'file' that
exercises the full depth of that nest of for loops? I'm not getting much
interesting output out of 'file' - the most interesting is from a core
file - and I'm curious.
 
--
Craig Ringer




More information about the plug mailing list