How do I check for UTF-8 encoded data (bytes) in python 2.4

77 views Asked by At

In higher versions of python i can do:

isinstance(s_out, bytes)

There is no 'bytes' in python2.4. Is there an equivalent of doing this in python2.4 which also works for all other python versions?

1

There are 1 answers

2
gelonida On BEST ANSWER
import sys

if sys.version_info < (2, 7):
    bytes = str


if isinstance(s_out, bytes):

I really don't know the context but wouldn't it better to upgrade at least to python 2.7 and not lose time trying to make code python 2.4 compatible.

I do not know the target systems and the OS, but could imagine that it is possible to install a more recent python and invest the time to make the code work with newer pythons.