From: Niranjan V. <nir...@ma...> - 2002-02-02 18:10:02
|
I am defining a class within another class. The code is class OuterClass: #Inner class definition # class InnerClass: #inner class constructor # def __init__(self): #Trying to print the OuterClass 'Name' instance variable #But i am getting NameError print OuterClass.name #outer class constructor # def __init__(self): self.name="outerclass" self.__age=23 def __printAge__(self,): print self.__age ic = self.InnerClass() if(__name__=='__main__'): oc = OuterClass() problem is i am not able to access (NameError is occuring) the Outerclass instance attributes inside the inner class constructor. How can i access the outerclass(both public and private) instance attributes inside inner class. It would be highly appreciated if anyone can give the solution for the same. Thanx in advance. Regards, Niranjan.V |