weakobj.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:core-framework 作者: RedhawkSDR 项目源码 文件源码
def boundmethod(func, callback=None):
    """
    Return a weakly-bound instance method from the given bound method. If
    callback is provided and not None, the callback will be called when the
    referenced object (the method's self) is about to be finalized; the weakly-
    bound instance method will be passed to the callback.

    If func is already a weakly-bound instance method, return a new weakly-
    bound instance method to the underlying bound method.
    """
    if inspect.ismethod(func):
        return WeakBoundMethod(func, callback)
    elif isinstance(func, bound_notification):
        return WeakNotification(func, callback)
    elif isinstance(func, _WeakCallable):
        return boundmethod(getref(func), callback)
    else:
        raise TypeError("can not create weakly-bound method from '%s' object" % (type(func).__name__,))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号