Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. class OneDigitNumericValue():
  2. def __init__(self, name):
  3. self.name = name
  4.  
  5. def __get__(self, instance, owner):
  6. if instance is None:
  7. return self
  8. return instance.__dict__[self.name]
  9.  
  10. def __set__(self, instance, value):
  11. instance.__dict__[self.name] = value
  12.  
  13. class A:
  14. name = OneDigitNumericValue("name")
  15.  
  16.  
  17. class OneDigitNumericValue():
  18. def __get__(self, instance, owner):
  19. if instance is None:
  20. return self
  21. return instance.__dict__[self]
  22.  
  23. def __set__(self, instance, value):
  24. instance.__dict__[self] = value
  25.  
  26. class A:
  27. name = OneDigitNumericValue()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement