Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. >>> class sample:
  2. ... def __init__(self, arr=[]):
  3. ... self.arr = arr
  4. ...
  5. >>> s1 = sample()
  6. >>> s2 = sample()
  7. >>> s1.arr
  8. []
  9. >>> s2.arr
  10. []
  11. >>> s2.arr.append(2)
  12. >>> s2.arr
  13. [2]
  14. >>> s1.arr
  15. [2]
  16. >>> s3 = sample([3])
  17. >>> s3.arr
  18. [3]
  19. >>> s2.arr
  20. [2]
  21. >>> s1.arr
  22. [2]
  23. >>> id(s1.arr) == id(s2.arr)
  24. True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement