Consider the following class:
from dataclasses import dataclass
@dataclass
class Test:
result: int = None
@dataclass
class Test2:
nested = Test()
result: int = None
class Mainthing:
def __init__(self, value):
self.value = value
self.results = Test2()
def Main(self):
value = self.value
self.results.result = value
self.results.nested.result = value
If I make an instance of the class:
x = Mainthing(1)
And call the Main()
function:
x.Main()
The results are as they should be,
x.results.result
Out[0]: 1
x.results.nested.result
Out[1]: 1
If I then delete the instance
del x
and make it again
x = Mainthing(1)
The x.results.result
is now None as i would expect, but the nested is not
x.results.nested.result
Out[]: 1
Why is that?