implementing abstract class in python code example
Example 1: abstract method python
from abc import ABC, abstractmethod
class AbstractClassExample(ABC):
def __init__(self, value):
self.value = value
super().__init__()
@abstractmethod
def do_something(self):
pass
Example 2: Abstraction example python
from abc import ABC,abstractclassmethod
class Parent(ABC):
@abstractclassmethod
def pqr(self):
pass
class Child(Parent):
def pqr(self):
print("PQR")
obj = Child()
obj.pqr()