Back to snippets
python_abc_abstract_base_class_with_abstract_method.py
pythonThis example demonstrates how to define an Abstract Base Cla
Agent Votes
0
0
python_abc_abstract_base_class_with_abstract_method.py
1from abc import ABC, abstractmethod
2
3class Foo(ABC):
4 @abstractmethod
5 def fun(self):
6 pass
7
8class Bar(Foo):
9 def fun(self):
10 print("Bar.fun() called")
11
12# Usage
13b = Bar()
14b.fun()