当前位置: 首页>>代码示例>>Python>>正文


Python Arguments.unpack方法代码示例

本文整理汇总了Python中pypy.interpreter.argument.Arguments.unpack方法的典型用法代码示例。如果您正苦于以下问题:Python Arguments.unpack方法的具体用法?Python Arguments.unpack怎么用?Python Arguments.unpack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pypy.interpreter.argument.Arguments的用法示例。


在下文中一共展示了Arguments.unpack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_unmatch_signature

# 需要导入模块: from pypy.interpreter.argument import Arguments [as 别名]
# 或者: from pypy.interpreter.argument.Arguments import unpack [as 别名]
    def test_unmatch_signature(self):
        space = DummySpace()
        args = Arguments(space, [1, 2, 3])
        sig = (["a", "b", "c"], None, None)
        data = args.match_signature(sig, [])
        new_args = args.unmatch_signature(sig, data)
        assert args.unpack() == new_args.unpack()

        args = Arguments(space, [1])
        sig = (["a", "b", "c"], None, None)
        data = args.match_signature(sig, [2, 3])
        new_args = args.unmatch_signature(sig, data)
        assert args.unpack() == new_args.unpack()

        args = Arguments(space, [1, 2, 3, 4, 5])
        sig = (["a", "b", "c"], "r", None)
        data = args.match_signature(sig, [])
        new_args = args.unmatch_signature(sig, data)
        assert args.unpack() == new_args.unpack()

        args = Arguments(space, [1], {"c": 3, "b": 2})
        sig = (["a", "b", "c"], None, None)
        data = args.match_signature(sig, [])
        new_args = args.unmatch_signature(sig, data)
        assert args.unpack() == new_args.unpack()

        args = Arguments(space, [1], {"c": 5})
        sig = (["a", "b", "c"], None, None)
        data = args.match_signature(sig, [2, 3])
        new_args = args.unmatch_signature(sig, data)
        assert args.unpack() == new_args.unpack()

        args = Arguments(space, [1], {"c": 5, "d": 7})
        sig = (["a", "b", "c"], None, "kw")
        data = args.match_signature(sig, [2, 3])
        new_args = args.unmatch_signature(sig, data)
        assert args.unpack() == new_args.unpack()

        args = Arguments(space, [1, 2, 3, 4, 5], {"e": 5, "d": 7})
        sig = (["a", "b", "c"], "r", "kw")
        data = args.match_signature(sig, [2, 3])
        new_args = args.unmatch_signature(sig, data)
        assert args.unpack() == new_args.unpack()

        args = Arguments(space, [], {}, w_stararg=[1], w_starstararg={"c": 5, "d": 7})
        sig = (["a", "b", "c"], None, "kw")
        data = args.match_signature(sig, [2, 3])
        new_args = args.unmatch_signature(sig, data)
        assert args.unpack() == new_args.unpack()

        args = Arguments(space, [1, 2], {"g": 9}, w_stararg=[3, 4, 5], w_starstararg={"e": 5, "d": 7})
        sig = (["a", "b", "c"], "r", "kw")
        data = args.match_signature(sig, [2, 3])
        new_args = args.unmatch_signature(sig, data)
        assert args.unpack() == new_args.unpack()
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:57,代码来源:test_argument.py

示例2: appcaller

# 需要导入模块: from pypy.interpreter.argument import Arguments [as 别名]
# 或者: from pypy.interpreter.argument.Arguments import unpack [as 别名]
 def appcaller(space, *args_w):
     if not isinstance(space, ObjSpace): 
         raise TypeError("first argument must be a space instance.")
     # redirect if the space handles this specially
     # XXX can this be factored a bit less flow space dependently?
     if hasattr(space, 'specialcases'):
         sc = space.specialcases
         if ApplevelClass in sc:
             ret_w = sc[ApplevelClass](space, self, name, args_w)
             if ret_w is not None: # it was RPython
                 return ret_w
     # the last argument can be an Arguments
     if not args_w:
         args = Arguments(space, [])
     else:
         args = args_w[-1]
         assert args is not None
         if not isinstance(args, AbstractArguments):
             args = Arguments(space, list(args_w))
         else:
             # ...which is merged with the previous arguments, if any
             if len(args_w) > 1:
                 more_args_w, more_kwds_w = args.unpack()
                 args = Arguments(space,
                                  list(args_w[:-1]) + more_args_w,
                                  more_kwds_w)
     w_func = self.wget(space, name) 
     return space.call_args(w_func, args)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:30,代码来源:gateway.py


注:本文中的pypy.interpreter.argument.Arguments.unpack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。