2018-03-30 18:19:23 -07:00
|
|
|
import re
|
|
|
|
import string
|
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2018-03-30 18:19:23 -07:00
|
|
|
def to_camel_case(name):
|
|
|
|
return "".join([
|
|
|
|
filter(
|
2018-04-06 13:58:59 -07:00
|
|
|
lambda c: c not in string.punctuation + string.whitespace, part
|
2018-03-30 18:19:23 -07:00
|
|
|
).capitalize()
|
|
|
|
for part in name.split("_")
|
|
|
|
])
|
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
|
|
|
def initials(name, sep_values=[" ", "_"]):
|
2018-03-30 18:19:23 -07:00
|
|
|
return "".join([
|
2018-04-06 13:58:59 -07:00
|
|
|
(s[0] if s else "")
|
2018-03-30 18:19:23 -07:00
|
|
|
for s in re.split("|".join(sep_values), name)
|
|
|
|
])
|
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2018-03-30 18:19:23 -07:00
|
|
|
def camel_case_initials(name):
|
2018-04-06 13:58:59 -07:00
|
|
|
return filter(lambda c: c.isupper(), name)
|
|
|
|
|
2018-03-31 18:57:21 -07:00
|
|
|
|
|
|
|
def complex_string(complex_num):
|
2018-04-06 13:58:59 -07:00
|
|
|
return filter(lambda c: c not in "()", str(complex_num))
|