What is the output of the following code ?
class TestAttr: def __init__(self): self.X = 'Pre' self.value_change(self.X) def value_change(self, var): var = 'Post' obj = TestAttr() print(obj.X)
Pre
Post
Error - cannot call value_change method from __init__
None
Even though value_change() is called from __intit_() , there is no change in self.X value.
So selef.X will remain unchanged
Comment here: