• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.compare函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pydron.translation.utils.compare函数的典型用法代码示例。如果您正苦于以下问题:Python compare函数的具体用法?Python compare怎么用?Python compare使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_as

 def test_as(self):
     src = """
     def test():
         with foo as bar:
             x + y
     """
     expected = """
     def test():
         mgr__U0 = foo
         exit__U0 = type(mgr__U0).__exit__
         value__U0 = type(mgr__U0).__enter__(mgr__U0)
         exc__U0 = True
         try:
             try:
                 bar = value__U0
                 x + y
             except:
                 exc__U0 = False
                 if not exit__U0(mgr__U0, *sys.exc_info()):
                     raise
         finally:
             if exc__U0:
                 exit__U0(mgr__U0, None, None, None)
     """
     utils.compare(src, expected, dewith.DeWith)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:25,代码来源:test_dewith.py


示例2: test_for_break_continue

 def test_for_break_continue(self):
     src = """
     def test():
         for a in b:
             if a:
                 break
             if b:
                 continue
             print "hi"
     """
     expected = """
     def test():
         interrupted__U0 = "0_none"
         for a in b:
             interrupted__U0 = "0_none"
             if a:
                 interrupted__U0 = "2_break"
             if interrupted__U0 == "0_none":
                 interrupted__U0 = "0_none"
                 if b:
                     interrupted__U0 = "1_continue"
                 if interrupted__U0 == "0_none":
                     print "hi"
             if interrupted__U0 == "1_continue":
                 interrupted__U0 = "0_none"
             if ((interrupted__U0 == '2_break') or (interrupted__U0 == '3_return')):
                 break
         if interrupted__U0 == "2_break":
             interrupted__U0 = "0_none"
         return None
     """
     utils.compare(src, expected, DeInterrupt)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:32,代码来源:test_deinterrupt.py


示例3: test_tryfinally

 def test_tryfinally(self):
     src = """
     def test():
         try:
             return "hi"
         finally:
             return "hello"
         print "world"
     """
     expected = """
     def test():
         returnvalue__U0 = None
         interrupted__U0 = "0_none"
         try:
             returnvalue__U0 = "hi"
             interrupted__U0 = "3_return"
         finally:
             interrupted__U1 = interrupted__U0
             returnvalue__U0 = "hello"
             interrupted__U0 = "3_return"
             interrupted__U0 = __pydron_max__(interrupted__U0, interrupted__U1)
         if interrupted__U0 == "0_none":
             print "world"
         return returnvalue__U0
     """
     utils.compare(src, expected, DeInterrupt)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:26,代码来源:test_deinterrupt.py


示例4: test_return_skip_nested

 def test_return_skip_nested(self):
     src = """
     def test():
         if a:
             if b:
                 return "Hello"
             print "a"
         print "b"
     """
     expected = """
     def test():
         returnvalue__U0 = None
         interrupted__U0 = "0_none"
         if a:
             interrupted__U0 = "0_none"
             if b:
                 returnvalue__U0 = 'Hello'
                 interrupted__U0 = '3_return'
             if interrupted__U0 == "0_none":
                 print "a"
         if interrupted__U0 == "0_none":
             print "b"
         return returnvalue__U0
     """
     utils.compare(src, expected, DeInterrupt)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:25,代码来源:test_deinterrupt.py


示例5: test_compare_oneop

 def test_compare_oneop(self):
     src = """
     test = a == b
     """
     expected = """
     test = a == b
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_decomplexexpr.py


示例6: test_augassign_simple

 def test_augassign_simple(self):
     src = """
     x += "s"
     """
     expected = """
     x += "s"
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_decomplexexpr.py


示例7: test_delete_single

 def test_delete_single(self):
     src = """
     del x[0]
     """
     expected = """
     del x[0]
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_decomplexexpr.py


示例8: test_attr

 def test_attr(self):
     src = """
     x = a.y
     """
     expected = """
     x = a.y
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_decomplexexpr.py


示例9: test_single_assignment

 def test_single_assignment(self):
     src = """
     x = 1
     """
     expected = """
     x = 1
     """
     utils.compare(src, expected, demultitarget.DeMultiTarget)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_demultitarget.py


示例10: test_locals_globals

 def test_locals_globals(self):
     src = """
     exec "code" in context, context2
     """
     expected = """
     __pydron_exec__("code", context2, context)
     """
     utils.compare(src, expected, deexec.DeExec)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_deexec.py


示例11: test_binop_single

 def test_binop_single(self):
     src = """
     x = 1 + 2
     """
     expected = """
     x = 1 + 2
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_decomplexexpr.py


示例12: test_call_no_args

 def test_call_no_args(self):
     src = """
     f()
     """
     expected = """
     f()
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_decomplexexpr.py


示例13: test_exec

 def test_exec(self):
     src = """
     exec "code"
     """
     expected = """
     __pydron_exec__("code", locals(), globals())
     """
     utils.compare(src, expected, deexec.DeExec)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_deexec.py


示例14: test_multi_assignment_num

 def test_multi_assignment_num(self):
     src = """
     x = y = 1
     """
     expected = """
     x = 1
     y = 1
     """
     utils.compare(src, expected, demultitarget.DeMultiTarget)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:9,代码来源:test_demultitarget.py


示例15: test_augassign

 def test_augassign(self):
     src = """
     x += "s" + "t"
     """
     expected = """
     binop__U0 = "s" + "t"
     x += binop__U0
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:9,代码来源:test_decomplexexpr.py


示例16: test_tuple_nested

 def test_tuple_nested(self):
     src = """
     (a,(b,c),d) = x
     """
     expected = """
     a,tuple__U0,d = x
     b,c = tuple__U0
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:9,代码来源:test_decomplexexpr.py


示例17: test_attr_lhr

 def test_attr_lhr(self):
     src = """
     (a+b).y = x
     """
     expected = """
     binop__U0 = a + b
     binop__U0.y = x
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:9,代码来源:test_decomplexexpr.py


示例18: test_binop

 def test_binop(self):
     src = """
     x = 1 + 2 * 3
     """
     expected = """
     binop__U0 = 2 * 3
     x = 1 + binop__U0
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:9,代码来源:test_decomplexexpr.py


示例19: test_subscript

 def test_subscript(self):
     src = """
     x = a[a+b]
     """
     expected = """
     binop__U0 = a + b
     x = a[binop__U0]
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:9,代码来源:test_decomplexexpr.py


示例20: test_repr

 def test_repr(self):
     src = """
     `a+b`
     """
     expected = """
     binop__U0 = a + b
     `binop__U0`
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:9,代码来源:test_decomplexexpr.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python filters.Filter类代码示例发布时间:2022-05-25
下一篇:
Python framework.LeafSystem类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap