inner class python code example
Example 1: muitiple inner classes in python
class Outer:
"""Outer Class"""
def __init__(self):
self.inner = self.Inner()
self._inner = self._Inner()
def show_classes(self):
print("This is Outer class")
print(inner)
print(_inner)
class Inner:
"""First Inner Class"""
def inner_display(self, msg):
print("This is Inner class")
print(msg)
class _Inner:
"""Second Inner Class"""
def inner_display(self, msg):
print("This is _Inner class")
print(msg)
Example 2: nested classes in python
class Outer:
class Inner:
pass
class InnerInner:
pass
class _Inner:
pass
pass