how to instantiate abstract class 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: python instantiate class
class Human(object):
def __init__(self, name, age):
self.name = name
self.age = age
def say_name(self):
print(f"My name is {self.name}.")
def say_age(self):
print(f"My age is {self.age}.")
bob = Human("Bob", 28)
bob.say_name()
bob.say_age()