Inner Class concept
Accessing Inner Class from the Outside
To access the inner class, create an object of the outer class, and then create an object of the inner class:
class Outer:
def __init__(self):
self.name = "Outer"
class Inner:
def __init__(self):
self.name = "Inner"
def display(self):
print("Hello from inner class")
outer = Outer()
inner = outer.Inner()
inner.display()
Comments
Post a Comment