All pastes #270311 Raw Edit

Someone

public text v1 · immutable
·published 2006-12-07 07:24 UTC
rendered paste body
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]