On Sat, 28 Apr 2012 11:35:12 -0700 Chris Rebert <c...@rebertia.com> wrote:
[...] > Correct. Pedantically, you can define __hash__() on mutable objects; > it's just not very useful or sensible, so people generally don't. As > http://docs.python.org/reference/datamodel.html#object.__hash__ states > [emphasis added]: > > "If a class defines *mutable* objects and implements a __cmp__() or > __eq__() method, it *should not* implement __hash__(), since hashable > collection implementations require that a object’s hash value is > immutable (if the object’s hash value changes, it will be in the wrong > hash bucket)." [...] How do function objects fit into this scheme? They have __hash__, __eq__, seem to work as dict keys and are mutable. Is it because their hash value doesn't change? Under what circumstances does an object's hash value change? -- John -- http://mail.python.org/mailman/listinfo/python-list