Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. class B:
  2. def __init__(self):
  3. self.count= 1
  4.  
  5. def setCount(self,count):
  6. self.count+=count
  7.  
  8. class A:
  9. def __init__(self):
  10. self.b = B
  11.  
  12. def inc(self):
  13. self.b.setCount(20)
  14. if __name__ == "__main__":
  15. a = A
  16. a.inc()
  17.  
  18. class B:
  19. def __init__(self):
  20. self.count = 1
  21.  
  22. def setCount(self, count):
  23. self.count += count
  24.  
  25.  
  26. class A:
  27. def __init__(self, obj):
  28. self.b = obj
  29.  
  30. def inc(self):
  31. self.b.setCount(20)
  32.  
  33.  
  34. if __name__ == "__main__":
  35. b = B()
  36. a = A(b)
  37. a.inc()
  38. print(b.count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement