我試圖從Python中獲取駝峯字符串的詳細名稱,但不知道如何處理該問題。從駝峯生成詳細名稱
這是用例:
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__)
我試圖實現在塊my
和class
從低級到大寫字母產生的檢測過渡的解決方案,但它是非常程序,不工作,它變得對於這樣一個簡單的任務太複雜了。
任何建議簡單的實施來解決問題?
argv的! findall!...我試圖在'\ B'上用're.split'分裂一個奇怪的形式,並且有一個超前的斷言,接下來的事情是大寫字母......這樣更好。 – mgilson