I have a class which has a lot of constants defined. I need to concatenate them by function call to make the code look cleaner. Below example should clarify this
I want to achieve this
class A:
@staticmethod
def __create_key(*keys):
return '.'.join(keys)
__CONST_A = 'const_a'
__CONST_B = 'const_b'
__CONST_C = 'const_c'
__CONST_D = __create_key(__CONST_A, __CONST_B, __CONST_C)
When I run this code I run into the following exception
TypeError: 'staticmethod' object is not callable
Rather than doing the following
class A:
@staticmethod
def __create_key(*keys):
return '.'.join(keys)
__CONST_A = 'const_a'
__CONST_B = 'const_b'
__CONST_C = 'const_c'
__CONST_D = __CONST_A + '.' + __CONST_B + '.' + __CONST_C
Or is there more elegant way to do this.
My main use case is that I have a bunch of these constant variables and I want to generate more constants by concatenating them