Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Meta(type):
- def __getattribute__(self, name):
- d = type.__getattribute__(self, "__dict__")
- if name not in d:
- raise AttributeError
- else:
- return d[name]
- class A(metaclass=Meta):
- x = 1
- class B(A):
- y = 2
- print(B.y) #2
- print(B().y) #2
- print(B().x) #1
- print(B.x) #AttributeError
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement