New style classes and rich comparison

Rainer Deyke rainerd at eldwood.com
Wed Dec 17 07:19:49 CET 2003


Stian Søiland wrote:
>>>> newbie.__hash__ = lambda x: 1337
>>>> hash(newbie)
> 1077345744
>>>> Newstyle.__hash__ = lambda x: 15
>>>> hash(newbie)
> 15
>
>
>
> Why is this?

Consider:

class A(object):
  def __hash__(self): return 5


print hash(A) # Which function should this call?


-- 
Rainer Deyke - rainerd at eldwood.com - http://eldwood.com






More information about the Python-list mailing list