This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 3rd, 2010  |  syntax: Python  |  size: 0.38 KB  |  views: 111  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. In [138]: class bad(object):
  2.     def __init__(self, str):
  3.         self._str = str
  4.     def __repr__(self):
  5.         return repr(self._str)
  6.     def __hash__(self):
  7.         return 1
  8.    .....:
  9.  
  10. In [145]: set([bad("cat"), bad("dog"), bad("fish")])
  11. Out[145]: set(['cat', 'fish', 'dog'])
  12.  
  13. In [146]: [hash(i) for i in set([bad("cat"), bad("dog"), bad("fish")])]
  14. Out[146]: [1, 1, 1]
clone this paste RAW Paste Data