Guest User

Untitled

a guest
Feb 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. >>> class obj:
  2. ... def __init__(self):
  3. ... self.counter = 0
  4. ... def inc(self):
  5. ... self.counter += 1
  6. ...
  7.  
  8. >>> a = obj()
  9. >>> from copy import copy
  10. >>> b = copy(a)
  11. >>> a.inc()
  12. >>> b.inc()
  13. >>> b.inc()
  14. >>> b.inc()
  15. >>> print a.counter, b.counter
  16. 1 3
Add Comment
Please, Sign In to add comment