New style classes and rich comparison
Stian Søiland
stain at stud.ntnu.no
Wed Dec 17 01:32:03 EST 2003
* Rainer Deyke spake thusly:
> Consider:
>
> class A(object):
> def __hash__(self): return 5
> print hash(A) # Which function should this call?
The hash method of A's class, ie. A.__class__.__hash__, usually
type.__hash__.
Hmmm. I think I get your point. hash and cmp and so on should call
A.__class__.hash(A) to be generic enough.
It's still confusing.. =) And how should I resolve this issue with my
Dummy class? (it's ok for the Dummy class itself to be a Dummy, but it
didn't work well to make Dummy = Dummy())
--
Stian Søiland Being able to break security doesn't make
Trondheim, Norway you a hacker more than being able to hotwire
http://stain.portveien.to/ cars makes you an automotive engineer. [ESR]
More information about the Python-list
mailing list