def chkstr ( s , v ) : if type ( s ) != str : raise TypeError ( "{var} must be str" . format ( var = v ) ) if not s : raise ValueError ( "{var} cannot be empty" . format ( var = v ) )
python if variable is str
Small routine for checking whether a string is empty even a string
def chkstr(s, v):
    """
    Small routine for checking whether a string is empty
    even a string

    :param s: the string in question
    :param v: variable name
    """
    if type(s) != str:
        raise TypeError("{var} must be str".format(var=v))
    if not s:
        raise ValueError("{var} cannot be empty".format(var=v))