def is_token(s):
    'Returns true if s is a string and is space-free.'
    if (not isinstance(s, str)):
        return False
    whitespace = re.compile('[ \t\r\n]+')
    split_str = whitespace.split(s)
    return ((len(split_str) == 1) and (s == split_str[0]))
Returns true if s is a string and is space-free.
def is_token(s):
    
    if (not isinstance(s, str)):
        return False
    whitespace = re.compile('[ \t\r\n]+')
    split_str = whitespace.split(s)
    return ((len(split_str) == 1) and (s == split_str[0]))