callback executes when object is deleted (argument is weak reference)
class Foo: pass
def cleanup(x):
print x, "deleted"
a = Foo()
b = weakref.ref(a, cleanup)
...
r = b() # Dereference. Returns a or None.
...
del a # Might cause cleanup() to be called
To dereference, simply call the weak reference as function
Returns the original object or None if it no longer exists