import sys

# True if we are running on Python 3.
PY3 = sys.version_info[0] == 3


if PY3:
    string_types = (str,)
else:  # pragma: no cover
    string_types = (basestring,)  # noqa

"""Compatibility support for Python 2 and 3."""

try:
    string_types = (basestring,)
except NameError:
    string_types = (str,)

Use feature detection instead of version detection for Python 2/3 compatibility.