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)
work as expected in python-2.x? Or will I need to check the version and use isinstance(x, basestr)
?
Specifically, in python-2.x:
>>>isinstance(u"test", str)
False
and python-3.x does not have u"foo"