def validate_string ( option , value ) : if isinstance ( value , string_type ) : return value raise TypeError ( "Wrong type for %s, value must be " "an instance of %s" % ( option , string_type . __name__ ) )
python 3 if type is str
Validates that value is an instance of basestring for Python 2 or str for Python 3 .
def validate_string(option, value):
    """Validates that 'value' is an instance of `basestring` for Python 2
    or `str` for Python 3.
    """
    if isinstance(value, string_type):
        return value
    raise TypeError("Wrong type for %s, value must be "
                    "an instance of %s" % (option, string_type.__name__))