Checking for binary data in a string

Lie Ryan lie.1296 at
Fri Jun 19 18:31:08 EDT 2009

Grant Edwards wrote:
> On 2009-06-19, Mitko Haralanov <mitko at> wrote:
>> I have a question about finding out whether a string contains
>> binary data?
> All strings contain binary data.  

Not quite, (python 2.x's) strings are binary data.

It just happens that it behaves like text when you appropriately
encode/decode it.

In python 3.x, the default string have evolved to unicode string, which
is a true text and the old string which contains arbitrary binary data
evolved into bytestring.

More information about the Python-list mailing list