def is_a_string(var, allow_none=False):
    """ Returns True if var is a string (ascii or unicode)

        Result             py-2  py-3
        -----------------  ----- -----
        b'bytes literal'   True  False
         'string literal'  True  True
        u'unicode literal' True  True

        Also returns True if the var is a numpy string (numpy.string_, numpy.unicode_).
    """
    return isinstance(var, six.string_types) or (var is None and allow_none)
Returns True if var is a string (ascii or unicode)

        Result             py-2  py-3
        -----------------  ----- -----
        b'bytes literal'   True  False
         'string literal'  True  True
        u'unicode literal' True  True

        Also returns True if the var is a numpy string (numpy.string_, numpy.unicode_).