From: Jan W. <j.w...@sc...> - 2002-02-04 14:04:02
|
On Fri, Feb 01, 2002 at 11:35:23PM -0500, Niranjan V. wrote: > I am defining a class within another class. The code is >=20 > class OuterClass: > class InnerClass: > def __init__(self): > print OuterClass.name > def __init__(self): > self.name=3D"outerclass" > self.__age=3D23 > def __printAge__(self,): > print self.__age > ic =3D self.InnerClass() > if(__name__=3D=3D'__main__'): > oc =3D OuterClass() Well, one problem I see here: Name and age are attributes of the instance= from the OuterClass. In InnerClass you ask the *class* for the attribute, whil= e only the instance has it. I don't think there is an easy way to get there. At first I thought neste= d scopes would help, but I didn't see how you get hold of the OuterClass in= stances attributes in the InnerClass. Cheerio, --=20 J.W...@sc... - Fon +4970719457-257 Fax-211 science+computing ag - Hagellocher Weg 71-75 - 72070 T=FCbingen Hit any key account manager to continue. |