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


Python pythonect.eval函数代码示例

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


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

示例1: test_multiple_stateful_x_eq_5_statement

    def test_multiple_stateful_x_eq_5_statement(self):

        locals_ = {}

        globals_ = {}

        pythonect.eval('xrange(1, 10) -> x = _', globals_, locals_)

        self.assertEqual('x' not in locals_ and 'x' not in globals_, True)
开发者ID:cocaman,项目名称:pythonect,代码行数:9,代码来源:test_eval.py

示例2: test_stateful_x_eq_5_statement

    def test_stateful_x_eq_5_statement(self):

        locals_ = {}

        globals_ = {}

        pythonect.eval('x = 5', globals_, locals_)

        self.assertEqual(pythonect.eval('1 -> [x == 5]', globals_, locals_), 1)
开发者ID:cocaman,项目名称:pythonect,代码行数:9,代码来源:test_eval.py

示例3: test_typeerror_exception_not_due_to_eval

    def test_typeerror_exception_not_due_to_eval(self):

        import sys
        import os

        orig_stderr = sys.stderr

        sys.stderr = open(os.devnull, 'w')

        self.assertEqual(pythonect.eval('1 -> socket.socket(socket.AF_INET, socket.SOCK_STREAM) -> _.connect("A","B")', {'sys': sys}, {'sys': sys}), False)

        sys.stderr = orig_stderr
开发者ID:Big-Data,项目名称:pythonect,代码行数:12,代码来源:test_eval.py

示例4: eval

def eval(source, locals_):

    return_value = None

    graph = None

    if source != "pass":

        if not isinstance(source, networkx.DiGraph):

            graph = parse(source)

        else:

            graph = source

        return_value = pythonect.eval(_hackersh_graph_transform(graph, locals_), {}, locals_)

    return return_value
开发者ID:INFOSECAPPS,项目名称:hackersh,代码行数:19,代码来源:eval.py

示例5: test_python_expr_str_2

    def test_python_expr_str_2(self):

        self.assertEqual(pythonect.eval("'Hello World'", {}, {}), "Hello World")
开发者ID:cocaman,项目名称:pythonect,代码行数:3,代码来源:test_eval.py

示例6: test_sub_expr_python_expr_int

    def test_sub_expr_python_expr_int(self):

        self.assertEqual(pythonect.eval('`1 + 1`', {}, {}), 2)
开发者ID:cocaman,项目名称:pythonect,代码行数:3,代码来源:test_eval.py

示例7: test_sub_expr_python_stmt_assignment

    def test_sub_expr_python_stmt_assignment(self):

        self.assertEqual(pythonect.eval('`x = 1`', {}, {}), self.input)
开发者ID:cocaman,项目名称:pythonect,代码行数:3,代码来源:test_eval.py

示例8: test_sub_expr_python_stmt_import

    def test_sub_expr_python_stmt_import(self):

        self.assertEqual(pythonect.eval('`import math`', {}, {}), self.input)
开发者ID:cocaman,项目名称:pythonect,代码行数:3,代码来源:test_eval.py

示例9: test_literal_int

    def test_literal_int(self):

        self.assertEqual(pythonect.eval('1', {}, {}), 1)
开发者ID:cocaman,项目名称:pythonect,代码行数:3,代码来源:test_eval.py

示例10: test_literal_bin

    def test_literal_bin(self):

        self.assertEqual(pythonect.eval('0b1', {}, {}), 1)
开发者ID:cocaman,项目名称:pythonect,代码行数:3,代码来源:test_eval.py

示例11: test_print_like_statement

    def test_print_like_statement(self):

        self.assertItemsEqual(pythonect.eval('range(1,10) -> print("Thread A")', {}, {}), [1, 2, 3, 4, 5, 6, 7, 8, 9])
开发者ID:cocaman,项目名称:pythonect,代码行数:3,代码来源:test_eval.py

示例12: test_autloader_within_array

    def test_autloader_within_array(self):

        self.assertItemsEqual(pythonect.eval('"Hello world" | [string.split]', {}, {}), ["Hello", "world"])
开发者ID:cocaman,项目名称:pythonect,代码行数:3,代码来源:test_eval.py

示例13: test_pseudo_none_str_fcn_return_value_as_url

    def test_pseudo_none_str_fcn_return_value_as_url(self):

        self.assertEqual(pythonect.eval('def ret_none(): return "None" -> def foobar(x): return x+1 -> 1 -> [email protected]_none()', {}, {}), 2)
开发者ID:cocaman,项目名称:pythonect,代码行数:3,代码来源:test_eval.py

示例14: test_pseudo_none_str_as_url

    def test_pseudo_none_str_as_url(self):

        self.assertEqual(pythonect.eval('def foobar(x): return x+1 -> 1 -> [email protected]"None"', {}, {}), 2)
开发者ID:cocaman,项目名称:pythonect,代码行数:3,代码来源:test_eval.py

示例15: test_multiprocess_program_sync

    def test_multiprocess_program_sync(self):

        self.assertEqual(pythonect.eval('import multiprocessing | start_pid = multiprocessing.current_process().pid | start_pid | str & | current_pid = multiprocessing.current_process().pid | 1 | current_pid != start_pid', {}, {}), 1)
开发者ID:cocaman,项目名称:pythonect,代码行数:3,代码来源:test_eval.py


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