class Foo object def __hash__ self return foo Foo hash foo foo print f

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
>>> class Foo(object):
... def __hash__(self): return 1
...
>>> foo = Foo()
>>> hash(foo)
1
>>> foo.a = 4
>>> print foo.a = 4
File "<stdin>", line 1
print foo.a = 4
^
SyntaxError: invalid syntax
>>> print foo.a
4
>>> d = {foo: 13}
>>> foo.a = 5
>>> d
{<__main__.Foo object at 0xb7da80cc>: 13}