def str_check ( * args , func = None ) : func = func or inspect . stack ( ) [ 2 ] [ 3 ] for var in args : if not isinstance ( var , ( str , collections . UserString , collections . abc . Sequence ) ) : name = type ( var ) . __name__ raise StringError ( f'Function {func} expected str, {name} got instead.' )
python check if function is string
Check if arguments are str type .
def str_check(*args, func=None):
    """Check if arguments are str type."""
    func = func or inspect.stack()[2][3]
    for var in args:
        if not isinstance(var, (str, collections.UserString, collections.abc.Sequence)):
            name = type(var).__name__
            raise StringError(
                f'Function {func} expected str, {name} got instead.')