New style classes and rich comparison

Rainer Deyke rainerd at eldwood.com
Wed Dec 17 01:19:49 EST 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