I have two files where each one contains a class:
# file1.py
class Class1:
def __init__(self):
self.d = dict()
@property
def get(self):
return self.d
obj1 = Class1()
obj1.d["a"] = 1
obj1.d["b"] = 2
# file2.py
from file1 import Class1
class Class2:
def print_val(self):
for i in Class1().get:
print(i)
I am trying to access the attribute d
from Class1 in Class2 without initializing Class1. The following currently returns an empty dict which makes sense.
Class2().print_val()
{}