Python basestring() Function
Description
basestring()basestring() is the superclass (parent class) of str and unicode, and it is also an abstract class, so it cannot be called or instantiated, but it can be used to determine whether an object is an instance of str or unicode. isinstance(obj, basestring) is equivalent to isinstance(obj, (str, unicode)).
Note: Python3 does not support the basestring() function, change tostr()function.
Syntax
The following is the syntax of the basestring() method:
basestring()
Parameters
- None
Return Value
None.
Examples
The following shows an example of using the basestring function:
>>>isinstance("Hello world", str)
True
>>> isinstance("Hello world", basestring)
True
Python Built-in Functions