Advertisement
Guest User

Untitled

a guest
Nov 17th, 2021
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. from abc import ABC
  2. from typing import Protocol, Type
  3.  
  4.  
  5. class Base(ABC):
  6.     pass
  7.  
  8.  
  9. class Foo(Base):
  10.     pass
  11.  
  12.  
  13. class Bar(Base):
  14.     pass
  15.  
  16.  
  17. class IApp(Protocol):
  18.     foo_or_bar: Type[Base]
  19.  
  20.  
  21. class Application(IApp, ABC):
  22.     def __init__(self, flag):
  23.         if flag:
  24.             self.foo_or_bar = Foo()
  25.         else:
  26.             self.foo_or_bar = Bar()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement