Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class B:
- def __init__(self):
- self.count= 1
- def setCount(self,count):
- self.count+=count
- class A:
- def __init__(self):
- self.b = B
- def inc(self):
- self.b.setCount(20)
- if __name__ == "__main__":
- a = A
- a.inc()
- class B:
- def __init__(self):
- self.count = 1
- def setCount(self, count):
- self.count += count
- class A:
- def __init__(self, obj):
- self.b = obj
- def inc(self):
- self.b.setCount(20)
- if __name__ == "__main__":
- b = B()
- a = A(b)
- a.inc()
- print(b.count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement