tputil.py 文件源码

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

项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码
def make_proxy(controller, type=_dummy, obj=_dummy):
    """ return a tranparent proxy controlled by the given
        'controller' callable.  The proxy will appear
        as a completely regular instance of the given
        type but all operations on it are send to the
        specified controller - which receives on
        ProxyOperation instance on each such call.
        A non-specified type will default to type(obj)
        if obj is specified.
    """
    if type is _dummy:
        if obj is _dummy:
            raise TypeError("you must specify a type or an instance obj of it")
        type = origtype(obj)
    def perform(opname, *args, **kwargs):
        operation = ProxyOperation(tp, obj, opname, args, kwargs)
        return controller(operation)
    tp = tproxy(type, perform)
    return tp
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号