# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. # # Translators: # python-doc bot, 2025 # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.9\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-01-03 16:35+0000\n" "PO-Revision-Date: 2025-09-22 17:54+0000\n" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/codeop.rst:2 msgid ":mod:`codeop` --- Compile Python code" msgstr ":mod:`codeop` --- 编译Python代码" #: ../../library/codeop.rst:10 msgid "**Source code:** :source:`Lib/codeop.py`" msgstr "**源代码:** :source:`Lib/codeop.py`" #: ../../library/codeop.rst:14 msgid "" "The :mod:`codeop` module provides utilities upon which the Python read-eval-" "print loop can be emulated, as is done in the :mod:`code` module. As a " "result, you probably don't want to use the module directly; if you want to " "include such a loop in your program you probably want to use the :mod:`code`" " module instead." msgstr "" ":mod:`codeop` 模块提供了可以模拟Python读取-执行-打印循环的实用程序,就像在 :mod:`code` " "模块中一样。因此,您可能不希望直接使用该模块;如果你想在程序中包含这样一个循环,你可能需要使用 :mod:`code` 模块。" #: ../../library/codeop.rst:20 msgid "There are two parts to this job:" msgstr "这个任务有两个部分:" #: ../../library/codeop.rst:22 msgid "" "Being able to tell if a line of input completes a Python statement: in " "short, telling whether to print '``>>>``' or '``...``' next." msgstr "能够判断一行输入是否完成了一个Python语句:简而言之,告诉我们是否要打印'\">>>\"'或'\"...\"'。" #: ../../library/codeop.rst:25 msgid "" "Remembering which future statements the user has entered, so subsequent " "input can be compiled with these in effect." msgstr "记住用户已输入了哪些 future 语句,这样后续的输入可以在这些语句被启用的状态下被编译。" #: ../../library/codeop.rst:28 msgid "" "The :mod:`codeop` module provides a way of doing each of these things, and a" " way of doing them both." msgstr ":mod:`codeop` 模块提供了分别以及同时执行这两个部分的方式。" #: ../../library/codeop.rst:31 msgid "To do just the former:" msgstr "只执行前一部分:" #: ../../library/codeop.rst:35 msgid "" "Tries to compile *source*, which should be a string of Python code and " "return a code object if *source* is valid Python code. In that case, the " "filename attribute of the code object will be *filename*, which defaults to " "``''``. Returns ``None`` if *source* is *not* valid Python code, but " "is a prefix of valid Python code." msgstr "" "尝试编译 *source*,这应当是一个 Python 代码字符串,并且在 *source* 是有效的 Python 代码时返回一个代码对象。 " "在此情况下,代码对象的 filename 属性将为 *filename*,其默认值为 ``''``。 如果 *source* *不是* " "有效的 Python 代码而是有效的 Python 代码的一个前缀时将返回 ``None``。" #: ../../library/codeop.rst:41 msgid "" "If there is a problem with *source*, an exception will be raised. " ":exc:`SyntaxError` is raised if there is invalid Python syntax, and " ":exc:`OverflowError` or :exc:`ValueError` if there is an invalid literal." msgstr "" "如果 *source* 存在问题,将引发异常。 如果存在无效的 Python 语法将引发 " ":exc:`SyntaxError`,而如果存在无效的字面值则将引发 :exc:`OverflowError` 或 :exc:`ValueError`。" #: ../../library/codeop.rst:45 msgid "" "The *symbol* argument determines whether *source* is compiled as a statement" " (``'single'``, the default), as a sequence of statements (``'exec'``) or as" " an :term:`expression` (``'eval'``). Any other value will cause " ":exc:`ValueError` to be raised." msgstr "" "*symbol* 参数确定 *source* 是作为一条语句 (对应默认值 ``'single'``),作为一系列语句 (``'exec'``) " "还是作为一个 :term:`expression` (``'eval'``) 进行编译。 任何其他值都将导致引发 :exc:`ValueError`。" #: ../../library/codeop.rst:52 msgid "" "It is possible (but not likely) that the parser stops parsing with a " "successful outcome before reaching the end of the source; in this case, " "trailing symbols may be ignored instead of causing an error. For example, a" " backslash followed by two newlines may be followed by arbitrary garbage. " "This will be fixed once the API for the parser is better." msgstr "" "解析器有可能(但很不常见)会在到达源码结尾之前停止解析并成功输出结果;在这种情况下,末尾的符号可能会被忽略而不是引发错误。 " "例如,一个反斜杠加两个换行符之后可以跟随任何无意义的符号。 一旦解析器 API 得到改进将修正这个问题。" #: ../../library/codeop.rst:61 msgid "" "Instances of this class have :meth:`__call__` methods identical in signature" " to the built-in function :func:`compile`, but with the difference that if " "the instance compiles program text containing a :mod:`__future__` statement," " the instance 'remembers' and compiles all subsequent program texts with the" " statement in force." msgstr "" "这个类的实例具有 :meth:`__call__` 方法,其签名与内置函数 :func:`compile` 相似,区别在于如果该实例编译了包含 " ":mod:`__future__` 语句的程序文本,则实例会‘记住’并使用已生效的语句编译所有后续程序文本。" #: ../../library/codeop.rst:70 msgid "" "Instances of this class have :meth:`__call__` methods identical in signature" " to :func:`compile_command`; the difference is that if the instance compiles" " program text containing a ``__future__`` statement, the instance " "'remembers' and compiles all subsequent program texts with the statement in " "force." msgstr "" "这个类的实例具有 :meth:`__call__` 方法,其签名与 :func:`compile_command` 相似;区别在于如果该实例编译了包含 " "``__future__`` 语句的程序文本,则实例会‘记住’并使用已生效的语句编译编译所有后续程序文本。"