__hash__ not in genindex.html

Thomas Güttler guettler at thomas-guettler.de
Wed May 28 05:38:14 EDT 2003


Hi!

I am subclassing from dict:

class Doc(dict):
    pass
    def __str__(self):
        return "<Doc: %s>" % dict.__str__(self)
    def __hash__(self):
        return id(self)

Since dicts are normaly unhashable, I did the __hash__ method
like above. Are there any problems with this method? Why don't
all dictionaries have __hash__ like this?

It would be nice if __hash__ would be in:
 http://www.python.org/doc/lib/genindex.html

 thomas





More information about the Python-list mailing list