The untimely dimise of a weak-reference
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Mon Aug 2 05:10:26 EDT 2010
Gregory Ewing a écrit :
(snip)
> import weakref
>
> class weakmethod(object):
>
> def __init__(self, bm):
> self.ref = weakref.ref(bm.im_self)
> self.func = bm.im_func
>
> def __call__(self, *args, **kwds):
> obj = self.ref()
> if obj is None:
> raise ValueError("Calling dead weak method")
> self.func(obj, *args, **kwds)
Would be better with :
return self.func(obj, *args, *kwds)
More information about the Python-list
mailing list