I\'m aware that I can use: isinstance(x, str) in python-3.x but I need to check if something is a string in python-2.x as well. Will isinstance(x, str)
isinstance(x, str)
If you're writing 2.x-and-3.x-compatible code, you'll probably want to use six:
from six import string_types isinstance(s, string_types)