I have two classes:
class A(object):
def __init__(self, b):
self b = b
class B(object):
def __init__(self, a):
self a = a
I’d like to init them like this:
a = A(b) b = B(a)
But I can’t since ‘b’ doesn’t exist when doing a = A(b). I have to do:
a = A() b = B(a) b.a = a
But that seems unclean. Is this solvable?
You could either make one class instantiate the other:
Or make one class tell the other about itself, like this: