Detecting Binary content in files

Grant Edwards invalid at invalid
Tue Mar 31 17:20:57 EDT 2009


On 2009-03-31, ritu <ritu_bhandari27 at yahoo.com> wrote:

> I'm wondering if Python has a utility to detect binary content in
> files?

Yes, check the file size.  If it's non-zero, then it has binary
content.

> Or if anyone has any ideas on how that can be accomplished? I
> haven't been able to find any useful information to accomplish
> this (my other option is to fire off a perl script from within
> m python script that will tell me whether the file is binary),
> so any pointers will be appreciated.

I'm afraid you're going to have define "binary" to get a useful
answer.  The definition you're using is apparently different
than mine. ;)

-- 
Grant Edwards                   grante             Yow! FEELINGS are cascading
                                  at               over me!!!
                               visi.com            



More information about the Python-list mailing list