Can a class instance variable be set equal to a class instance variable of another class that was created inside a function? The code below seems to work (a.var = [5, []]
) after the call to func()
but I want to make sure that I am not missing anything:
def func():
class C:
def __init__(self):
self.var = [[] for _ in np.arange(2)]
c = C()
c.var[0] = 5
a.var = c.var
class A:
def __init__(self):
self.id = 0
self.var = [[] for _ in np.arange(2)]
if __name__ == "__main__":
a = A()
func()