Testing for file type

BartlebyScrivener rpdooling at gmail.com
Mon May 22 17:36:21 CEST 2006

In the Python Cookbook, 2ed, page 25, there's a script by Andrew Dalke
that uses the same heureistic criteria that Perl does and analyzes a
string and deems it binary if it contains any nulls or if more than 30%
of its characters have the high bit set or are strange control codes.

There's a follow on script that uses the same test on files.


More information about the Python-list mailing list