Advertisement
here2share

# b_set_and_get.py

Oct 18th, 2021
1,033
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. # b_set_and_get.py
  2.  
  3. def make_point(x, y):
  4.     def point():
  5.         return ("Point"+str((point.get_x,point.get_y)))
  6.     def set_x(value):
  7.         point.get_x = value
  8.     def set_y(value):
  9.         point.get_y = value
  10.     # Adding getters and setters
  11.     point.get_x = x
  12.     point.set_x = set_x
  13.     point.get_y = y
  14.     point.set_y = set_y
  15.     return point
  16. 0
  17. ppp = make_point(123, 456)
  18.  
  19. print ppp.get_x
  20. print ppp.get_y
  21. print ppp()
  22. ppp.set_x(21)
  23. ppp.set_y(99)
  24. print ppp()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement