Advertisement
Guest User

Untitled

a guest
Jul 30th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. class A(type):
  2.     def __setattr__(self, name, value):
  3.         print("From metaclass: ", name)
  4.  
  5. class B(metaclass= A):
  6.     def __init__(self): pass
  7.  
  8.     def __setattr__(self, name, value):
  9.         print("From B: ", name)
  10.         object.__setattr__(self, name, value)
  11.  
  12. obj = B()
  13. obj.t = 4
  14. print("Value of t is set and it is: ", obj.t)
  15. B.r = 3  #<--- how to initialize this?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement