Basically I have 1 class object (Let's say Class A), which contains some value assigned to a variable (attribute of class, let's say self.use). There are multiple other classes, (B, C..) and functions creating instance of that class A. I want to share self.use among all the objects of the class A (can be created by any module, any function)
For Example :
class Core(object):
def __init__(self):
self.use = True
if self.use:
main()
def main(self):
# doing some stuff
The above class has an attribute self.use, main function is called based on the value of self.use. Now I have other modules which are using Core class :
class Helper(object):
def func1(self):
self.core = Core()
def func2(self):
self.core = Core()
In above Helper class, I've created 2 objects of Core class. What I want if self.use is to be created only once no matter how many objects are created by any functions.
PS. Please don't tell me to create Core object only once, and not from each function. There are lot of such modules and functions which can not be changed at the moment.