I want to understand in my case if I should use static or class method. The idea: I'm not editing any class variable, but I'm using this variable.
example 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
example2:
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
What is the best practice?
example2? Have you tried running that code? (btw you should be calling your variable aclassvariable)static_variable. This means that you can choose which ever one suits the circumstances you are in.