I have a situation where I want to use class instance declared in one file in second file. As a small example, see the below code :
How I am solving it as of now?
File2 (To be executed):
# Prog2:
from prog1 import *
cls1.dict["name"] = "John"
File1
# Prog1:
class Myclass(object):
def __init__(self):
self.dict = {}
cls1 = Myclass()
import prog2
print cls1.dict["name"]
Is there a better way of doing it?