checking whether a string is text or binary

Rick Dooling rpdooling at
Tue Oct 28 23:21:30 CET 2014

I'm an English major who hacks scripts together to do things as needed.

I used this code from the Python Cookbook for years.

Especially when I need to convert old WPD files to markdown, some of which don't even have file extensions, so the code helps determine what kind of file it is I am reading in conversion scripts.

I tried to convert the code using 2to3 and it broke.

The error I get when using Python 3 is on this line:

_null_trans = string.maketrans("", "")

and the error reads

AttributeError: 'module' object has no attribute 'maketrans'

Any help? I barely understand the whole unicode business, but any guidance in updating the code would be much appreciated.



More information about the Python-list mailing list