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


Python Py.compile_command_flags方法代码示例

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


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

示例1: compile_command

# 需要导入模块: from org.python.core import Py [as 别名]
# 或者: from org.python.core.Py import compile_command_flags [as 别名]
def compile_command(source, filename="<input>", symbol="single"):
    r"""Compile a command and determine whether it is incomplete.

    Arguments:

    source -- the source string; may contain \n characters
    filename -- optional filename from which source was read; default
                "<input>"
    symbol -- optional grammar start symbol; "single" (default) or "eval"

    Return value / exceptions raised:

    - Return a code object if the command is complete and valid
    - Return None if the command is incomplete
    - Raise SyntaxError, ValueError or OverflowError if the command is a
      syntax error (OverflowError and ValueError can be produced by
      malformed literals).
    """
    if symbol not in ['single','eval']:
        raise ValueError,"symbol arg must be either single or eval"
    return Py.compile_command_flags(source,filename,symbol,Py.getCompilerFlags(),0)
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:23,代码来源:codeop.py

示例2: execfile

# 需要导入模块: from org.python.core import Py [as 别名]
# 或者: from org.python.core.Py import compile_command_flags [as 别名]
# 
# Test for bug 1758838
#
# execfile(<any file>) should not throw a NullPointerException
#
# The error only shows up in interactive interpretation (type "single" for the compilation).
# But we cannot use InteractiveInterpreter here since it catches all Exceptions,
# therefore we do the compilation 'by hand'.
#

from org.python.core import Py
from org.python.core import PySystemState
from org.python.util import PythonInterpreter

PySystemState.initialize()
interp = PythonInterpreter()
code = Py.compile_command_flags("execfile('test401/to_be_executed.py')", "<input>", "single", None, 1)
interp.exec(code)
开发者ID:nelmiux,项目名称:DataManagement,代码行数:20,代码来源:test401.py


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