Advertisement
Guest User

Untitled

a guest
Apr 16th, 2020
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. class Base:
  2.     __handlers = []
  3.  
  4.     @staticmethod
  5.     def handler(cls):
  6.         def wrapper():
  7.             Base.add_handler(cls)
  8.  
  9.         wrapper()
  10.  
  11.     @classmethod
  12.     def add_handler(cls, view):
  13.         cls.__handlers.append(view)
  14.  
  15.  
  16. class View:
  17.     pass
  18.  
  19.  
  20. @Base.handler
  21. class First(View):
  22.     pass
  23.  
  24.  
  25. bot = Base()
  26. print(bot._Base__handlers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement