I cannot find documentation about when exactly the class can refer to itself. In the future, he will fail. This is because the class was created but not initialized to the next line __init__, right?
class A(object):
class_var = 'Hi'
def __init__(self, var=A.class_var):
self.var = var
So, in the case where I want to do this, this is the best solution:
class A(object):
class_var = 'Hi'
def __init__(self, var=None)
if var is None:
var = A.class_var
self.var = var
Any help or documentation appreciated!
source
share