Идея: я не редактирую какую-либо переменную класса, но использую эту переменную.
пример 1:
Код: Выделить всё
class RandClass():
static_variable = "some rand value to static variable"
@classmethod
def func_that_return_string_contain_static_variable(cls):
return "some rand string" + cls.static_variable
Код: Выделить всё
class RandClass():
static_variable = "some rand value to static variable"
@staticmethod
def func_that_return_string_contain_static_variable():
return "some rand string" + RandClass.static_variable
Подробнее здесь: https://stackoverflow.com/questions/734 ... hod-python
Мобильная версия