def camel_to_snake_case ( name ) : pattern = r'[A-Z][a-z]+|[A-Z]+(?![a-z])' return '_' . join ( map ( str . lower , re . findall ( pattern , name ) ) )
python regexp case insensitive
Takes a camelCased string and converts to snake_case .
def camel_to_snake_case(name):
    """Takes a camelCased string and converts to snake_case."""
    pattern = r'[A-Z][a-z]+|[A-Z]+(?![a-z])'
    return '_'.join(map(str.lower, re.findall(pattern, name)))