Use my new super module propertize

This commit is contained in:
adrienmalin
2018-08-19 04:49:56 +02:00
parent 68cf21392c
commit f13962890f
5 changed files with 141 additions and 3 deletions

View File

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
import re
first_cap_re = re.compile('(.)([A-Z][a-z]+)')
all_cap_re = re.compile('([a-z0-9])([A-Z])')
def snake_case(s):
"""
Convert a CamelCase string to snake_case
"""
s1 = first_cap_re.sub(r'\1_\2', s)
return all_cap_re.sub(r'\1_\2', s1).lower()