I have few dummy function names and I want to transform them as follows:
sample case 1
input : getDataType
output: Data_Type
sample case 2
input: getDatasetID
output: Dataset_ID
My code is as below:
def apiNames(funcName):
name = funcName.split("get")[1]
print(''.join('_' + char if char.isupper() else char
for char in name).lstrip('_'))
apiNames("getDataType")
apiNames("getDatasetID")
it works for case 1 but not for case 2
case 1 Output:
Data_Type
case 2 Output:
Dataset_I_D