Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Extending from ABC makes
- this class abstract
- '''
- from abc import ABC, abstractmethod
- class A(ABC):
- def __init__(self):
- self.a = 40
- # Abstract methods have to be annotated
- @abstractmethod
- def some_method(self):
- # abstract methods can, but usually
- # don't have an implementation
- pass
- class B(A):
- def __init__(self):
- super().__init__()
- self.b = 50
- # Class B now has to implement
- # some_method
- def some_method(self):
- print('some_method in B')
- objekt = B()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement