How to find out if a Python object is a string?

compatibility, python, string, types

Solution

Python 2

Use `isinstance(obj, basestring)` for an object-to-test `obj`.

Docs.

Problem

How can I check if a Python object is a string (either regular or Unicode)?

Original source

Related problems