Vedanta Barooah wrote: > in a python nested class is it possible to change the value of the > parent class's variable without actually creating an instance of the > parent class
Python nested classs are like *static* Java nested classes. Non-static Java classes are very different in that they have an implicit reference to an instance of the enclosing class. This is why you can instantiate non-static inner classes only in the context (= non-static method) of a specific object. There is no direct equivalent to this in Python, so you have to do the steps yourself. - the constructor takes an additional argument, the 'outer' object, which has to be kept in the object: def __init__ (self, outer, ...): self.outer = outer - when creating the inner object, the outer object must be passed to the constructor obj = InnerClass (self) - the outer object must be explicitely referenced: self.outer.increase (20) Daniel -- http://mail.python.org/mailman/listinfo/python-list