Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> class Foo(object):
- ... pass
- ...
- >>> myfoo=Foo()
- >>> myfoo.url="google.com"
- >>> mydict={myfoo:"myfoo all up in there"}
- >>>
- >>> def new_hash(self):
- ... return hash(self.url)
- ...
- >>> Foo.__hash__=new_hash
- >>>
- >>> mydict[myfoo]="myfoo all up in there again!!!"
- >>> mydict
- {<__main__.Foo object at 0x1050e8cd0>: 'myfoo all up in there again!!!', <__main__.Foo object at 0x1050e8cd0>: 'myfoo all up in there'}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement