Could somebody please explain the following code to me.
class InnerTest:
def __init__(self, value = 0):
self.value = value
class OuterTest:
def __init__(self, inner_test = InnerTest()):
self.inner_test = inner_test
a = OuterTest()
b = OuterTest()
a.inner_test.value = 42
print b.inner_test.value
It prints 42, I expected 0.
I meant to create two instances of OuterTest, which would contain a distinct instance of InnerTest each. Instead I got two instances of OuterTest which reference the same instance of InnerTest.
Also what would be a correct way to implement what I wanted please?