I want to calculate a value in the class that stays the same for all instances of that class and is calculated only once
class A:
a = calculate_a()
def calculate_a():
return 5
first, What should I set as reference for calculate_a()
in a = calculate_a()
?
self.calculate_a()
and A.calculate_a()
both are not correct (unresolved reference)
what I need is, when the second instance is created, the calculate_a()
is not called again.
instance1 = A() -> calls calculate_a() to set value for a;
instance2 = A() -> uses the value of a calculated above without calling calculate_a