socketIO-client/experiments/t5.py
2013-02-11 08:32:22 -08:00

30 lines
436 B
Python

import callableweakref
class O(object):
def __init__(self):
self.p = P(self.f)
def __del__(self):
print '__del__()'
def f(self):
print 'f()'
class P(object):
def __init__(self, parentMethod):
self.parentMethod = callableweakref.ref(parentMethod)
def show(self):
print self.parentMethod
def run(self):
self.parentMethod()()
o = O()
o.p.show()
o.p.run()