One can replace unicode
with u''.__class__
to handle the missing unicode
class in Python 3. For both Python 2 and 3, you can use the construct
isinstance(unicode_or_str, u''.__class__)
or
type(unicode_or_str) == type(u'')
Depending on your further processing, consider the different outcome:
Python 3
>>> isinstance('text', u''.__class__)
True
>>> isinstance(u'text', u''.__class__)
True
Python 2
>>> isinstance(u'text', u''.__class__)
True
>>> isinstance('text', u''.__class__)
False