True if d is a string and it's an existing directory.

def dir_param_valid(d):
    '''True if d is a string and it's an existing directory.'''
    r = True
    if not isinstance(d, str) :
        r = False
        raise TypeError
    if not os.path.isdir(d):
        r = False
        raise ValueError
    return r