The class basestring is the parent class for
the two string types, str and unicode. It exists not because you can call it (you
can't), but for type testing. To test whether some value
is an instance
of either type of string, use this predicate:
s
isinstance(s, basestring)
See Section 21.12, “isinstance(): Is a value an instance of
some class or type?”.