fork download
  1. #!/usr/local/lib/python3
  2.  
  3. class w():
  4. def __init__(self, x):
  5. self.x = x
  6.  
  7. def __hash__(self):
  8. return True
  9.  
  10. def __eq__(self, y):
  11. return False
  12.  
  13. ww = w(12)
  14.  
  15. print(ww)
  16. print(hash(ww))
  17.  
  18. q = {
  19. ww: 333,
  20. 1: 'qwe',
  21. 'qqq': 'asd',
  22. (1, 2): 'zxc'
  23. }
  24.  
  25. print(q['qqq'])
  26. print(q[ww])
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
<__main__.w object at 0x2b15f1cea080>
1
asd
333