May-24-2023, 05:37 PM
Perhaps you mean this
class A: pass class B: def __init__(self, spam): self.spam = spam class C: def __init__(self, eggs): self.eggs = eggs a = A() # instantiate A b = B(a) bb = B(a) c = C(a) # objects b, bb and c all share the same A instance assert b.spam is bb.spam and b.spam is c.eggs