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. rick -- http://mail.python.org/mailman/listinfo/python-list