class foo: pass d={} # Classes are immutable. Seems reasonable d[foo] = 'foo is a class' f = foo() # Instances are mutable, aren't they? # So why does this work? d[f]='f is an object' # Just to show that it is mutable... f.val='this is an instance of f' print d[f]