Advertisement
joejoinerr

Python: Abstract base class for a progress bar

Feb 6th, 2023 (edited)
1,100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. from abc import ABC
  2.  
  3.  
  4. class ProgressBar(ABC):
  5.     @abstractmethod
  6.     def update(self, amount: int = 1):
  7.         pass
  8.  
  9.     @abstractmethod
  10.     def close(self):
  11.         pass
  12.        
  13.     def __enter__(self):
  14.         return self
  15.    
  16.     def __exit__(self, exc_type, exc_value, exc_tb):
  17.         self.close()
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement