I'm trying to obtain verbose names from CamelCase strings in Python but have no idea how to approach the problem.
This is the usecase:
class MyClass(object):
def verbose_name(self, camelcase):
return "my class"
# ^-- here I need a way to calculate the
# value using the camelcase argument
def __str__(self):
return self.verbose_name(self.__class__.__name__)
I tried to implement a solution where the chunks my
and class
are generated detecting transitions from lower to uppercase letters, but it's very procedural, doesn't work and it's becoming too complex for such a simple task.
Any suggestion for a simple implementation to solve the problem?