Рассмотрим следующий код:
Фактический файл
[test.py]
from util.rx import RX
msg = RX.get_msg('Albert!')
print(msg)
Файл класса утилит
[rx.py]
class RX(object):
def __init__(self):
self.data = 'Hello ' # How to define this var? (self.data or cls.data)
@classmethod
def msg(cls, name):
return self.data + name
# Shall I use "@staticmethod" in below? If once yes, then how to call the another
# method inside the same class? (i.e, without 'self' or 'cls')
@classmethod
def get_msg(cls, name = None):
return cls.msg(name)
Ожидаемый результат: Привет, Альберт!
Есть идеи, тогда, пожалуйста!Спасибо.