Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Abstract Base Class with abc

  • abc

  • abstractmethod

  • abc

from abc import ABC, abstractmethod

class Base(ABC):
    def __init__(self, name):
        self.name = name

    @abstractmethod
    def foo(self):
        pass

    @abstractmethod
    def bar(self):
        pass