If I understand your requirement correctly, you want to split a camel case string on the Case boundary. Regex can be quite handy here
Try the following implementation
>>> ' '.join(re.findall("([A-Z][^A-Z]*)","MyClass")).strip()
'My Class'
The above implementation would fail if the name is non CamelCase conforming. In such cases, make the caps
optional
>>> test_case = ["MyClass","My","myclass","my_class","My_Class","myClass"]
>>> [' '.join(re.findall("([A-Z]?[^A-Z]*)",e)) for e in test_case]
['My Class ', 'My ', 'myclass ', 'my_class ', 'My_ Class ', 'my Class ']