From c80de0e2cc5b34941a8d731fa1f2b38a26bde19b Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Sat, 9 Dec 2023 12:10:19 +0800 Subject: [PATCH 1/7] feat: translate `library/ast.po` --- library/ast.po | 543 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 445 insertions(+), 98 deletions(-) diff --git a/library/ast.po b/library/ast.po index e021b7c35f..7e9f51e462 100644 --- a/library/ast.po +++ b/library/ast.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2023, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -20,7 +19,7 @@ msgstr "" #: ../../library/ast.rst:2 msgid ":mod:`ast` --- Abstract Syntax Trees" -msgstr "" +msgstr ":mod:`ast` --- 抽象語法樹 (Abstract Syntax Trees)" #: ../../library/ast.rst:14 msgid "**Source code:** :source:`Lib/ast.py`" @@ -33,6 +32,9 @@ msgid "" "with each Python release; this module helps to find out programmatically " "what the current grammar looks like." msgstr "" +":mod:`ast` 模組可以幫助 Python 應用程式處理 Python 抽象語法樹狀資料結構。抽象" +"語法本身可能會隨著每個 Python 版本發布而改變;此模組有助於以程式化的方式來得" +"知當前語法的面貌。" #: ../../library/ast.rst:23 msgid "" @@ -43,18 +45,22 @@ msgid "" "syntax tree can be compiled into a Python code object using the built-in :" "func:`compile` function." msgstr "" +"要生成抽象語法樹,可以透過將 :data:`ast.PyCF_ONLY_AST` 作為旗標傳遞給內建函" +"式 :func:`compile` 或使用此模組所提供的 :func:`parse` 輔助函式。結果將會是一" +"個物件的樹,其類別都繼承自 :class:`ast.AST`。可以使用內建的 :func:`compile` " +"函式將抽象語法樹編譯成 Python 程式碼物件。" #: ../../library/ast.rst:33 msgid "Abstract Grammar" -msgstr "" +msgstr "抽象文法 (Abstract Grammar)" #: ../../library/ast.rst:35 msgid "The abstract grammar is currently defined as follows:" -msgstr "" +msgstr "抽象文法目前定義如下:" #: ../../library/ast.rst:42 msgid "Node classes" -msgstr "" +msgstr "節點 (Node) 類別" #: ../../library/ast.rst:46 msgid "" @@ -63,6 +69,9 @@ msgid "" "`above `. They are defined in the :mod:`_ast` C module " "and re-exported in :mod:`ast`." msgstr "" +"這是所有 AST 節點類別的基礎。實際的節點類別是衍生自 :file:`Parser/Python." +"asdl` 檔案,該檔案在\\ :ref:`上方 ` 重現。它們被定義於 :" +"mod:`_ast` 的 C 模組中,並於 :mod:`ast` 中重新匯出。" #: ../../library/ast.rst:51 msgid "" @@ -74,12 +83,17 @@ msgid "" "rules with alternatives (aka \"sums\"), the left-hand side class is " "abstract: only instances of specific constructor nodes are ever created." msgstr "" +"抽象文法中為每個左側符號定義了一個類別(例如,:class:`ast.stmt` 或 :class:" +"`ast.expr`\\ )。另外,也為每個右側的建構函式 (constructor) 定義了一個類別;" +"這些類別繼承自左側樹的類別。例如,:class:`ast.BinOp` 繼承自 :class:`ast." +"expr`。對於具有替代方案(即為「和 (sums)」)的生產規則,左側類別是抽象的:僅" +"有特定建構函式節點的實例會被建立。" #: ../../library/ast.rst:64 msgid "" "Each concrete class has an attribute :attr:`_fields` which gives the names " "of all child nodes." -msgstr "" +msgstr "每個具體類別都有一個屬性 :attr:`_fields`,它會給出所有子節點的名稱。" #: ../../library/ast.rst:67 msgid "" @@ -87,6 +101,8 @@ msgid "" "the type as defined in the grammar. For example, :class:`ast.BinOp` " "instances have an attribute :attr:`left` of type :class:`ast.expr`." msgstr "" +"具體類別的每個實例對於每個子節點都有一個屬性,其型別如文法中所定義。例如,:" +"class:`ast.BinOp` 實例具有型別為 :class:`ast.expr` 的屬性 :attr:`left`。" #: ../../library/ast.rst:71 msgid "" @@ -96,6 +112,9 @@ msgid "" "lists. All possible attributes must be present and have valid values when " "compiling an AST with :func:`compile`." msgstr "" +"如果這些屬性在文法中被標記為可選(使用問號),則該值可能為 ``None``。如果屬性" +"可以有零個或多個值(用星號標記),則這些值將表示為 Python 串列。使用 :func:" +"`compile` 編譯 AST 時,所有可能的屬性都必須存在並且具有有效值。" #: ../../library/ast.rst:82 msgid "" @@ -108,6 +127,12 @@ msgid "" "the node. The UTF-8 offset is recorded because the parser uses UTF-8 " "internally." msgstr "" +":class:`ast.expr` 和 :class:`ast.stmt` 子類別的實例具有 :attr:`lineno`、:" +"attr:`col_offset`、:attr:`end_lineno` 和 :attr:`end_col_offset` 屬性。:attr:" +"`lineno` 和 :attr:`end_lineno` 是原始文本跨度 (source text span) 的第一個和最" +"後一個列號(1-indexed,因此第一列號是 1)以及 :attr:`col_offset` 和 :attr:" +"`end_col_offset` 是生成節點的第一個和最後一個標記對應的 UTF-8 位元組偏移量。" +"會記錄 UTF-8 偏移量是因為剖析器 (parser) 內部使用 UTF-8。" #: ../../library/ast.rst:91 msgid "" @@ -116,43 +141,49 @@ msgid "" "one can get the source segment of a one-line expression node using " "``source_line[node.col_offset : node.end_col_offset]``." msgstr "" +"請注意,編譯器不需要知道結束位置,因此為可選的。結束偏移量在最後一個符號\\ *" +"之後*,例如可以使用 ``source_line[node.col_offset : node.end_col_offset]`` 來" +"獲取單列運算式節點 (expression node) 的原始片段。" #: ../../library/ast.rst:96 msgid "" "The constructor of a class :class:`ast.T` parses its arguments as follows:" -msgstr "" +msgstr ":class:`ast.T` 類別的建構函式按以下方式剖析其引數:" #: ../../library/ast.rst:98 msgid "" "If there are positional arguments, there must be as many as there are items " "in :attr:`T._fields`; they will be assigned as attributes of these names." msgstr "" +"如果有位置引數,則必須與 :attr:`T._fields` 中的項目一樣多;它們將被賦値為這些" +"名稱的屬性。" #: ../../library/ast.rst:100 msgid "" "If there are keyword arguments, they will set the attributes of the same " "names to the given values." -msgstr "" +msgstr "如果有關鍵字引數,它們會將相同名稱的屬性設定為給定值。" #: ../../library/ast.rst:103 msgid "" "For example, to create and populate an :class:`ast.UnaryOp` node, you could " "use ::" msgstr "" +"例如,要建立並填充 (populate) :class:`ast.UnaryOp` 節點,你可以使用: ::" #: ../../library/ast.rst:115 msgid "or the more compact ::" -msgstr "" +msgstr "或更簡潔的: ::" #: ../../library/ast.rst:122 msgid "Class :class:`ast.Constant` is now used for all constants." -msgstr "" +msgstr ":class:`ast.Constant` 類別現在用於所有常數。" #: ../../library/ast.rst:126 msgid "" "Simple indices are represented by their value, extended slices are " "represented as tuples." -msgstr "" +msgstr "以它們的值表示簡單索引,擴充切片 (slice) 則以元組 (tuple) 表示。" #: ../../library/ast.rst:131 msgid "" @@ -161,6 +192,9 @@ msgid "" "will be removed in future Python releases. In the meantime, instantiating " "them will return an instance of a different class." msgstr "" +"舊的類別 :class:`ast.Num`、:class:`ast.Str`、:class:`ast.Bytes`、:class:`ast." +"NameConstant` 和 :class:`ast.Ellipsis` 仍然可用,但它們將在未來的 Python 釋出" +"版本中移除。與此同時,實例化它們將回傳不同類別的實例。" #: ../../library/ast.rst:138 msgid "" @@ -168,6 +202,8 @@ msgid "" "available, but they will be removed in future Python releases. In the " "meantime, instantiating them will return an instance of a different class." msgstr "" +"舊的類別 :class:`ast.Index` 和 :class:`ast.ExtSlice` 仍然可用,但它們將在未來" +"的 Python 版本中刪除。同時,實例化它們會回傳不同類別的實例。" #: ../../library/ast.rst:144 msgid "" @@ -175,48 +211,61 @@ msgid "" "adapted from the fantastic `Green Tree Snakes `__ project and all its contributors." msgstr "" +"這裡顯示的特定節點類別的描述最初是從出色的 `Green Tree Snakes `__ 專案和所有貢獻者那裡改編而來" +"的。" #: ../../library/ast.rst:153 msgid "Root nodes" -msgstr "" +msgstr "根節點" #: ../../library/ast.rst:157 msgid "" "A Python module, as with :ref:`file input `. Node type generated " "by :func:`ast.parse` in the default ``\"exec\"`` *mode*." msgstr "" +"一個 Python 模組,與\\ :ref:`檔案輸入 ` 一樣。由 :func:`ast." +"parse` 在預設的 ``\"exec\"`` *mode* 下生成的節點型別。" #: ../../library/ast.rst:160 msgid "*body* is a :class:`list` of the module's :ref:`ast-statements`." -msgstr "" +msgstr "*body* 是模組的\\ :ref:`ast-statements` :class:`list`。" #: ../../library/ast.rst:162 msgid "" "*type_ignores* is a :class:`list` of the module's type ignore comments; see :" "func:`ast.parse` for more details." msgstr "" +"*type_ignores* 是模組的忽略型別註解的 :class:`list`;有關更多詳細資訊,請參" +"閱 :func:`ast.parse`。" #: ../../library/ast.rst:179 msgid "" "A single Python :ref:`expression input `. Node type " "generated by :func:`ast.parse` when *mode* is ``\"eval\"``." msgstr "" +"單個 Python :ref:`運算式輸入 `,為當 *mode* 是 " +"``\"eval\"`` 時,:func:`ast.parse` 生成的節點型別。" #: ../../library/ast.rst:182 msgid "" "*body* is a single node, one of the :ref:`expression types `." -msgstr "" +msgstr "*body* 是單個節點,是\\ :ref:`運算式型別 `\\ 之一。" #: ../../library/ast.rst:194 msgid "" "A single :ref:`interactive input `, like in :ref:`tut-interac`. " "Node type generated by :func:`ast.parse` when *mode* is ``\"single\"``." msgstr "" +"單個\\ :ref:`互動式輸入 `,和\\ :ref:`tut-interac`\\ 中所述的相" +"似。為當 *mode* 是 ``\"single\"`` 時 :func:`ast.parse` 生成的節點型別。" #: ../../library/ast.rst:197 msgid "*body* is a :class:`list` of :ref:`statement nodes `." msgstr "" +"*body* 是\\ :ref:`陳述式節點 (statement nodes) ` 的 :class:" +"`list`。" #: ../../library/ast.rst:216 msgid "" @@ -224,23 +273,26 @@ msgid "" "versions prior to 3.5 didn't support :pep:`484` annotations. Node type " "generated by :func:`ast.parse` when *mode* is ``\"func_type\"``." msgstr "" +"函式的舊式型別註解的表示法,因為 3.5 之前的 Python 版本不支援 :pep:`484` 註" +"釋。當 *mode* 為 ``\"func_type\"`` 時 :func:`ast.parse` 產生的節點型別。" #: ../../library/ast.rst:220 msgid "Such type comments would look like this::" -msgstr "" +msgstr "這種型別的註解看起來像這樣: ::" #: ../../library/ast.rst:226 msgid "" "*argtypes* is a :class:`list` of :ref:`expression nodes `." msgstr "" +"*argtypes* 是\\ :ref:`運算式節點 `\\ 的 :class:`list`。" #: ../../library/ast.rst:228 msgid "*returns* is a single :ref:`expression node `." -msgstr "" +msgstr "*returns* 是單個\\ :ref:`運算式節點 `。" #: ../../library/ast.rst:246 msgid "Literals" -msgstr "" +msgstr "文本 (Literals)" #: ../../library/ast.rst:250 msgid "" @@ -250,6 +302,9 @@ msgid "" "container types (tuples and frozensets) if all of their elements are " "constant." msgstr "" +"一個常數值。``Constant`` 文本的 ``value`` 屬性包含它所代表的 Python 物件。表" +"示的值可以是簡單型別,例如數字、字串或 ``None``,但如果它們的所有元素都是常" +"數,也可以是不可變的 (immutable) 容器型別(元組和凍結集合 (frozensets))。" #: ../../library/ast.rst:264 msgid "" @@ -257,32 +312,35 @@ msgid "" "contains a single formatting field and nothing else the node can be isolated " "otherwise it appears in :class:`JoinedStr`." msgstr "" +"表示 f 字串 (f-string) 中的單個格式化欄位的節點。如果字串包含單個格式欄位並且" +"沒有其他內容,則可以隔離 (isolate) 該節點,否則它將出現在 :class:`JoinedStr` " +"中。" #: ../../library/ast.rst:268 msgid "" "``value`` is any expression node (such as a literal, a variable, or a " "function call)." -msgstr "" +msgstr "``value`` 為任何運算式節點(例如文字、變數或函式呼叫)。" #: ../../library/ast.rst:270 msgid "``conversion`` is an integer:" -msgstr "" +msgstr "``conversion`` 是一個整數:" #: ../../library/ast.rst:272 msgid "-1: no formatting" -msgstr "" +msgstr "-1: 無格式化" #: ../../library/ast.rst:273 msgid "115: ``!s`` string formatting" -msgstr "" +msgstr "115: ``!s`` 字串格式化" #: ../../library/ast.rst:274 msgid "114: ``!r`` repr formatting" -msgstr "" +msgstr "114:``!r`` 重複格式化化" #: ../../library/ast.rst:275 msgid "97: ``!a`` ascii formatting" -msgstr "" +msgstr "97: ``!a`` ascii 格式化" #: ../../library/ast.rst:277 msgid "" @@ -290,12 +348,15 @@ msgid "" "the value, or ``None`` if no format was specified. Both ``conversion`` and " "``format_spec`` can be set at the same time." msgstr "" +"``format_spec`` 是一個 :class:`JoinedStr` 節點,表示值的格式,``None`` 則代表" +"未指定格式。``conversion`` 和 ``format_spec`` 可以同時設定。" #: ../../library/ast.rst:284 msgid "" "An f-string, comprising a series of :class:`FormattedValue` and :class:" "`Constant` nodes." msgstr "" +"一個 f 字串,包含一系列 :class:`FormattedValue` 和 :class:`Constant` 節點。" #: ../../library/ast.rst:313 msgid "" @@ -303,10 +364,12 @@ msgid "" "``ctx`` is :class:`Store` if the container is an assignment target (i.e. " "``(x,y)=something``), and :class:`Load` otherwise." msgstr "" +"串列或元組。``elts`` 保存表示元素的節點串列。如果容器是賦值目標(即 ``(x," +"y)=something`` ),則 ``ctx`` 是 :class:`Store`,否則是 :class:`Load`。" #: ../../library/ast.rst:339 msgid "A set. ``elts`` holds a list of nodes representing the set's elements." -msgstr "" +msgstr "一個集合。``elts`` 保存表示集合之元素的節點串列。" #: ../../library/ast.rst:354 msgid "" @@ -314,6 +377,9 @@ msgid "" "keys and the values respectively, in matching order (what would be returned " "when calling :code:`dictionary.keys()` and :code:`dictionary.values()`)." msgstr "" +"一個字典 (dictionary)。``keys`` 和 ``values`` 分別按匹配順序保存表示鍵和值的" +"節點串列(為呼叫 :code:`dictionary.keys()` 和 :code:`dictionary.values()` 時" +"將回傳的內容)。" #: ../../library/ast.rst:358 msgid "" @@ -321,16 +387,18 @@ msgid "" "be expanded goes in the ``values`` list, with a ``None`` at the " "corresponding position in ``keys``." msgstr "" +"當使用字典文本進行字典解包 (unpack) 時,要擴充的運算式位於 ``values`` 串列" +"中,在 ``keys`` 中的相應位置有一個 ``None``。" #: ../../library/ast.rst:376 msgid "Variables" -msgstr "" +msgstr "變數" #: ../../library/ast.rst:380 msgid "" "A variable name. ``id`` holds the name as a string, and ``ctx`` is one of " "the following types." -msgstr "" +msgstr "一個變數名稱。``id`` 將名稱以字串形式保存,且 ``ctx`` 是以下型別之一。" #: ../../library/ast.rst:388 msgid "" @@ -338,6 +406,8 @@ msgid "" "new value to it, or to delete it. Variable references are given a context to " "distinguish these cases." msgstr "" +"變數參照可用於載入變數的值、為其分配新值或刪除它。變數參照被賦予情境 " +"(context) 來區分這些情況。" #: ../../library/ast.rst:421 msgid "" @@ -345,10 +415,12 @@ msgid "" "class:`Name` node. This type must be used when building a :class:`Call` node " "with ``*args``." msgstr "" +"一個 ``*var`` 變數參照。``value`` 保存變數,通常是一個 :class:`Name` 節點。在" +"使用 ``*args`` 建置 :class:`Call` 節點時必須使用此型別。" #: ../../library/ast.rst:446 msgid "Expressions" -msgstr "" +msgstr "運算式" #: ../../library/ast.rst:450 msgid "" @@ -358,28 +430,37 @@ msgid "" "`Constant`, a :class:`Name`, a :class:`Lambda`, a :class:`Yield` or :class:" "`YieldFrom` node." msgstr "" +"當運算式(例如函式呼叫)本身作為陳述式出現且未使用或儲存其回傳值時,它將被包" +"裝在此容器中。``value`` 保存此區段 (section) 中的一個其他節點::class:" +"`Constant`、:class:`Name`、:class:`Lambda`、:class:`Yield` 或 :class:" +"`YieldFrom`" #: ../../library/ast.rst:469 msgid "" "A unary operation. ``op`` is the operator, and ``operand`` any expression " "node." msgstr "" +"一元運算 (unary operation)。``op`` 是運算子,``operand`` 是任何運算式節點。" #: ../../library/ast.rst:478 msgid "" "Unary operator tokens. :class:`Not` is the ``not`` keyword, :class:`Invert` " "is the ``~`` operator." msgstr "" +"一元運算子標記。 :class:`Not` 是 ``not`` 關鍵字、:class:`Invert` 是 ``~`` 運" +"算子。" #: ../../library/ast.rst:492 msgid "" "A binary operation (like addition or division). ``op`` is the operator, and " "``left`` and ``right`` are any expression nodes." msgstr "" +"二元運算 (binary operation)(如加法或除法)。 ``op`` 是運算子、``left`` 和 " +"``right`` 是任意運算式節點。" #: ../../library/ast.rst:519 msgid "Binary operator tokens." -msgstr "" +msgstr "二元運算子 token。" #: ../../library/ast.rst:524 msgid "" @@ -388,14 +469,17 @@ msgid "" "operator, such as ``a or b or c``, are collapsed into one node with several " "values." msgstr "" +"布林運算 'or' 或 'and'。``op`` 是 :class:`Or` 或 :class:`And`。``values`` 是" +"有所涉及的值。使用同一運算子的連續操作(例如 ``a or b or c``\\ )會被折疊為具" +"有多個值的一個節點。" #: ../../library/ast.rst:529 msgid "This doesn't include ``not``, which is a :class:`UnaryOp`." -msgstr "" +msgstr "這不包括 ``not``,它是一個 :class:`UnaryOp`。" #: ../../library/ast.rst:545 msgid "Boolean operator tokens." -msgstr "" +msgstr "布林運算子 token。" #: ../../library/ast.rst:550 msgid "" @@ -403,44 +487,54 @@ msgid "" "comparison, ``ops`` the list of operators, and ``comparators`` the list of " "values after the first element in the comparison." msgstr "" +"兩個或多個值的比較。``left`` 是比較中的第一個值、``ops`` 是運算子串列、" +"``comparators`` 是要比較的第一個元素之後值的串列。" #: ../../library/ast.rst:579 msgid "Comparison operator tokens." -msgstr "" +msgstr "比較運算子 token。" #: ../../library/ast.rst:584 msgid "" "A function call. ``func`` is the function, which will often be a :class:" "`Name` or :class:`Attribute` object. Of the arguments:" msgstr "" +"一個函式呼叫。``func`` 是該函式,通常是一個 :class:`Name` 或 :class:" +"`Attribute` 物件。而在引數中:" #: ../../library/ast.rst:587 msgid "``args`` holds a list of the arguments passed by position." -msgstr "" +msgstr "``args`` 保存按位置傳遞的引數串列。" #: ../../library/ast.rst:588 msgid "" "``keywords`` holds a list of :class:`.keyword` objects representing " "arguments passed by keyword." msgstr "" +"``keywords`` 保存一個 :class:`.keyword` 物件串列,表示透過關鍵字傳遞的引數。" #: ../../library/ast.rst:591 msgid "" "When creating a ``Call`` node, ``args`` and ``keywords`` are required, but " "they can be empty lists." msgstr "" +"建立 ``Call`` 節點時會需要 ``args`` 和 ``keywords``,但它們可以是空串列。" #: ../../library/ast.rst:615 msgid "" "A keyword argument to a function call or class definition. ``arg`` is a raw " "string of the parameter name, ``value`` is a node to pass in." msgstr "" +"函式呼叫或類別定義的關鍵字引數。``arg`` 是參數名稱的原始字串,``value`` 是要" +"傳入的節點。" #: ../../library/ast.rst:621 msgid "" "An expression such as ``a if b else c``. Each field holds a single node, so " "in the following example, all three are :class:`Name` nodes." msgstr "" +"像是 ``a if b else c`` 之類的運算式。每個欄位都包含一個節點,因此在以下範例" +"中,所有三個都是 :class:`Name` 節點。" #: ../../library/ast.rst:636 msgid "" @@ -449,6 +543,9 @@ msgid "" "``ctx`` is :class:`Load`, :class:`Store` or :class:`Del` according to how " "the attribute is acted on." msgstr "" +"屬性的存取,例如 ``d.keys``。``value`` 是一個節點,通常是一個 :class:`Name`。" +"``attr`` 是一個屬性名稱的字串,``ctx`` 根據屬性的作用方式可能是 :class:" +"`Load`、:class:`Store` 或 :class:`Del`。" #: ../../library/ast.rst:653 msgid "" @@ -457,10 +554,13 @@ msgid "" "`Assign` node in which the first argument can be multiple nodes, in this " "case both ``target`` and ``value`` must be single nodes." msgstr "" +"一個附名運算式 (named expression)。該 AST 節點由賦值運算式運算子(也稱為海象" +"運算子)產生。相對於 :class:`Assign` 節點之第一個引數可為多個節點,在這種情況" +"下 ``target`` 和 ``value`` 都必須是單個節點。" #: ../../library/ast.rst:669 msgid "Subscripting" -msgstr "" +msgstr "下標 (Subscripting)" #: ../../library/ast.rst:673 msgid "" @@ -469,6 +569,10 @@ msgid "" "class:`Tuple` and contain a :class:`Slice`. ``ctx`` is :class:`Load`, :class:" "`Store` or :class:`Del` according to the action performed with the subscript." msgstr "" +"一個下標,例如 ``l[1]``。``value`` 是下標物件(通常是序列或對映)。``slice`` " +"是索引、切片或鍵。它可以是一個 :class:`Tuple` 並包含一個 :class:`Slice`。根據" +"下標執行的操作不同,``ctx`` 可以是 :class:`Load`、:class:`Store` 或 :class:" +"`Del`。" #: ../../library/ast.rst:697 msgid "" @@ -476,10 +580,12 @@ msgid "" "occur only inside the *slice* field of :class:`Subscript`, either directly " "or as an element of :class:`Tuple`." msgstr "" +"常規切片(形式為 ``lower:upper`` 或 ``lower:upper:step``\\ )。只能直接出現" +"在 :class:`Subscript` 的 *slice* 欄位內,或者作為 :class:`Tuple` 的元素出現。" #: ../../library/ast.rst:714 msgid "Comprehensions" -msgstr "" +msgstr "綜合運算式 (comprehensions)" #: ../../library/ast.rst:721 msgid "" @@ -487,10 +593,12 @@ msgid "" "comprehensions. ``elt`` (or ``key`` and ``value``) is a single node " "representing the part that will be evaluated for each item." msgstr "" +"串列和集合綜合運算、生成器運算式和字典綜合運算。``elt``\\ (或 ``key`` 和 " +"``value``\\ )是單個節點,表示各個項目會被求值 (evaluate) 的部分。" #: ../../library/ast.rst:725 msgid "``generators`` is a list of :class:`comprehension` nodes." -msgstr "" +msgstr "``generators`` 是一個 :class:`comprehension` 節點的串列。" #: ../../library/ast.rst:767 msgid "" @@ -499,22 +607,27 @@ msgid "" "``iter`` is the object to iterate over. ``ifs`` is a list of test " "expressions: each ``for`` clause can have multiple ``ifs``." msgstr "" +"綜合運算中的一個 ``for`` 子句。``target`` 是用於每個元素的參照 - 通常是 :" +"class:`Name` 或 :class:`Tuple` 節點。``iter`` 是要疊代的物件。``ifs`` 是測試" +"運算式的串列:每個 ``for`` 子句可以有多個 ``ifs``。" #: ../../library/ast.rst:772 msgid "" "``is_async`` indicates a comprehension is asynchronous (using an ``async " "for`` instead of ``for``). The value is an integer (0 or 1)." msgstr "" +"``is_async`` 表示綜合運算式是非同步的(使用 ``async for`` 而不是 ``for`` )。" +"該值為整數(0 或 1)。" #: ../../library/ast.rst:841 msgid "Statements" -msgstr "" +msgstr "陳述式" #: ../../library/ast.rst:845 msgid "" "An assignment. ``targets`` is a list of nodes, and ``value`` is a single " "node." -msgstr "" +msgstr "一個賦值。``targets`` 是節點串列,``value`` 是單個節點。" #: ../../library/ast.rst:847 msgid "" @@ -522,12 +635,14 @@ msgid "" "Unpacking is represented by putting a :class:`Tuple` or :class:`List` within " "``targets``." msgstr "" +"``targets`` 中的多個節點表示為每個節點分配相同的值。解包是透過在 ``targets`` " +"中放置一個 :class:`Tuple` 或 :class:`List` 來表示的。" #: ../../library/ast.rst:853 ../../library/ast.rst:1161 #: ../../library/ast.rst:1366 ../../library/ast.rst:1891 msgid "" "``type_comment`` is an optional string with the type annotation as a comment." -msgstr "" +msgstr "``type_comment`` 是一個可選字串,其中的註解為型別註釋。" #: ../../library/ast.rst:883 msgid "" @@ -538,6 +653,11 @@ msgid "" "integer set to True for a :class:`Name` node in ``target`` that do not " "appear in between parenthesis and are hence pure names and not expressions." msgstr "" +"帶有型別註釋的賦值。``target`` 是單個節點,可以是 :class:`Name`、:class:" +"`Attribute` 或 :class:`Subscript`。``annotation`` 是註釋,例如 :class:" +"`Constant` 或 :class:`Name` 節點。``value`` 是單個可選節點。``simple`` 是一個" +"布林整數,對於 ``target`` 中的 :class:`Name` 節點會設定為 True,它不會出現在" +"括號之間,因此是純名稱而不是運算式。" #: ../../library/ast.rst:938 msgid "" @@ -546,12 +666,17 @@ msgid "" "context), ``op`` is :class:`Add`, and ``value`` is a :class:`Constant` with " "value for 1." msgstr "" +"增加賦值 (augmented assignment),例如 ``a += 1``。在下面的範例中,``target`` " +"是 ``x`` 的 :class:`Name` 節點(帶有 :class:`Store` 情境),``op`` 是 :class:" +"`Add`,``value`` 是一個值為 1 的 :class:`Constant`。" #: ../../library/ast.rst:943 msgid "" "The ``target`` attribute cannot be of class :class:`Tuple` or :class:`List`, " "unlike the targets of :class:`Assign`." msgstr "" +"與 :class:`Assign` 的目標不同,``target`` 屬性不能屬於 :class:`Tuple` 或 :" +"class:`List` 類別。" #: ../../library/ast.rst:960 msgid "" @@ -559,22 +684,29 @@ msgid "" "normally a :class:`Call` or :class:`Name`, or ``None`` for a standalone " "``raise``. ``cause`` is the optional part for ``y`` in ``raise x from y``." msgstr "" +"一個 ``raise`` 陳述式。``exc`` 是要引發的例外物件,通常是 :class:`Call` 或 :" +"class:`Name`,或者獨立 ``raise`` 的則為 ``None``。``cause`` 是 ``raise x " +"from y`` 中的可選部分 ``y``。" #: ../../library/ast.rst:977 msgid "" "An assertion. ``test`` holds the condition, such as a :class:`Compare` node. " "``msg`` holds the failure message." msgstr "" +"一個斷言 (assertion)。``test`` 保存條件,例如 :class:`Compare` 節點。``msg`` " +"保存失敗訊息。" #: ../../library/ast.rst:993 msgid "" "Represents a ``del`` statement. ``targets`` is a list of nodes, such as :" "class:`Name`, :class:`Attribute` or :class:`Subscript` nodes." msgstr "" +"代表一個 ``del`` 陳述式。``targets`` 是節點串列,例如 :class:`Name`、:class:" +"`Attribute` 或 :class:`Subscript` 節點。" #: ../../library/ast.rst:1011 msgid "A ``pass`` statement." -msgstr "" +msgstr "一個 ``pass`` 陳述式。" #: ../../library/ast.rst:1024 msgid "" @@ -583,20 +715,23 @@ msgid "" "ref:`type parameters `, and ``value`` is the value of the " "type alias." msgstr "" +"透過 :keyword:`type` 陳述式建立的\\ :ref:`型別別名 (type alias) `。``name`` 是別名的名稱、``type_params`` 是\\ :ref:`型別參數 (type " +"parameter) ` 的串列、``value`` 是型別別名的值。" #: ../../library/ast.rst:1042 msgid "" "Other statements which are only applicable inside functions or loops are " "described in other sections." -msgstr "" +msgstr "其他僅適用於函式或迴圈內部的陳述式將在其他部分中描述。" #: ../../library/ast.rst:1046 msgid "Imports" -msgstr "" +msgstr "引入 (imports)" #: ../../library/ast.rst:1050 msgid "An import statement. ``names`` is a list of :class:`alias` nodes." -msgstr "" +msgstr "一個 import 陳述式。``names`` 是 :class:`alias` 節點的串列。" #: ../../library/ast.rst:1067 msgid "" @@ -605,28 +740,35 @@ msgid "" "import foo``. ``level`` is an integer holding the level of the relative " "import (0 means absolute import)." msgstr "" +"代表 ``from x import y``。``module`` 是 'from' 名稱的原始字串,前面沒有任何的" +"點 (dot),或者對於諸如 ``from . import foo`` 之類的陳述式為 ``None``。" +"``level`` 是一個整數,保存相對引入的級別(0 表示絕對引入)。" #: ../../library/ast.rst:1089 msgid "" "Both parameters are raw strings of the names. ``asname`` can be ``None`` if " "the regular name is to be used." msgstr "" +"這兩個參數都是名稱的原始字串。如果要使用常規名稱,``asname`` 可以為 " +"``None``。" #: ../../library/ast.rst:1106 msgid "Control flow" -msgstr "" +msgstr "流程控制" #: ../../library/ast.rst:1109 msgid "" "Optional clauses such as ``else`` are stored as an empty list if they're not " "present." -msgstr "" +msgstr "諸如 ``else`` 之類的可選子句如果不存在,則將被儲存為空串列。" #: ../../library/ast.rst:1114 msgid "" "An ``if`` statement. ``test`` holds a single node, such as a :class:" "`Compare` node. ``body`` and ``orelse`` each hold a list of nodes." msgstr "" +"一個 ``if`` 陳述式。``test`` 保存單個節點,例如 :class:`Compare` 節點。" +"``body`` 和 ``orelse`` 各自保存一個節點串列。" #: ../../library/ast.rst:1117 msgid "" @@ -634,6 +776,8 @@ msgid "" "appear as extra :class:`If` nodes within the ``orelse`` section of the " "previous one." msgstr "" +"``elif`` 子句在 AST 中沒有特殊表示,而是在前一個子句的 ``orelse`` 部分中作為" +"額外的 :class:`If` 節點出現。" #: ../../library/ast.rst:1152 msgid "" @@ -644,22 +788,29 @@ msgid "" "Those in ``orelse`` are executed if the loop finishes normally, rather than " "via a ``break`` statement." msgstr "" +"一個 ``for`` 迴圈。 ``target`` 保存迴圈賦予的變數,為單個 :class:`Name`、:" +"class:`Tuple`、:class:`List`、:class:`Attribute` 或 :class:`Subscript` 節點。" +"``iter`` 保存要迴圈跑過的項目,也為單個節點。``body`` 和 ``orelse`` 包含要執" +"行的節點串列。如果迴圈正常完成,則執行 ``orelse`` 中的內容,而不是透過 " +"``break`` 陳述式執行。" #: ../../library/ast.rst:1187 msgid "" "A ``while`` loop. ``test`` holds the condition, such as a :class:`Compare` " "node." -msgstr "" +msgstr "一個 ``while`` 迴圈。``test`` 保存條件,例如 :class:`Compare` 節點。" #: ../../library/ast.rst:1214 msgid "The ``break`` and ``continue`` statements." -msgstr "" +msgstr "``break`` 和 ``continue`` 陳述式。" #: ../../library/ast.rst:1249 msgid "" "``try`` blocks. All attributes are list of nodes to execute, except for " "``handlers``, which is a list of :class:`ExceptHandler` nodes." msgstr "" +"``try`` 區塊。除 ``handlers`` 是 :class:`ExceptHandler` 節點的串列外,其他所" +"有屬性都是要執行之節點的串列。" #: ../../library/ast.rst:1295 msgid "" @@ -667,6 +818,9 @@ msgid "" "the same as for :class:`Try` but the :class:`ExceptHandler` nodes in " "``handlers`` are interpreted as ``except*`` blocks rather then ``except``." msgstr "" +"``try`` 區塊,後面跟著 ``except*`` 子句。這些屬性與 :class:`Try` 相同,但是 " +"``handlers`` 中的 :class:`ExceptHandler` 節點被直譯 (interpret) 為 " +"``except*`` 區塊而不是 ``except``。" #: ../../library/ast.rst:1327 msgid "" @@ -675,6 +829,10 @@ msgid "" "clause). ``name`` is a raw string for the name to hold the exception, or " "``None`` if the clause doesn't have ``as foo``. ``body`` is a list of nodes." msgstr "" +"單個 ``except`` 子句。``type`` 是會被匹配的例外型別,通常是一個 :class:" +"`Name` 節點(或者 ``None`` 表示會捕捉到所有例外的 ``except:`` 子句)。" +"``name`` 是用於保存例外的名稱之原始字串,如果子句沒有 ``as foo`` ,則為 " +"``None``。``body`` 是節點串列。" #: ../../library/ast.rst:1361 msgid "" @@ -682,6 +840,8 @@ msgid "" "representing the context managers, and ``body`` is the indented block inside " "the context." msgstr "" +"一個 ``with`` 區塊。``items`` 是表示情境管理器的 :class:`withitem` 節點串列," +"``body`` 是情境內的縮進區塊。" #: ../../library/ast.rst:1371 msgid "" @@ -690,10 +850,13 @@ msgid "" "`Name`, :class:`Tuple` or :class:`List` for the ``as foo`` part, or ``None`` " "if that isn't used." msgstr "" +"``with`` 區塊中的單個情境管理器。``context_expr`` 是情境管理器,通常是一個 :" +"class:`Call` 節點。``Optional_vars`` 是 ``as foo`` 部分的 :class:`Name`、:" +"class:`Tuple` 或 :class:`List`,或者如果不使用則為 ``None`` 。" #: ../../library/ast.rst:1404 msgid "Pattern matching" -msgstr "" +msgstr "模式匹配 (pattern matching)" #: ../../library/ast.rst:1409 msgid "" @@ -701,6 +864,8 @@ msgid "" "object that is being matched against the cases) and ``cases`` contains an " "iterable of :class:`match_case` nodes with the different cases." msgstr "" +"一個 ``match`` 陳述式。``subject`` 保存匹配的主題(與案例匹配的物件)," +"``cases`` 包含具有不同案例的可疊代 :class:`match_case` 節點。" #: ../../library/ast.rst:1417 msgid "" @@ -709,18 +874,23 @@ msgid "" "`AST` nodes produced for patterns differ from those produced for " "expressions, even when they share the same syntax." msgstr "" +"``match`` 陳述式中的單個案例模式。``pattern`` 包含主題將與之匹配的匹配模式。" +"請注意,為模式生成的 :class:`AST` 節點與為運算式生成的節點不同,即使它們共享" +"相同的語法。" #: ../../library/ast.rst:1422 msgid "" "The ``guard`` attribute contains an expression that will be evaluated if the " "pattern matches the subject." -msgstr "" +msgstr "``guard`` 屬性包含一個運算式,如果模式與主題匹配,則將對該運算式求值。" #: ../../library/ast.rst:1425 msgid "" "``body`` contains a list of nodes to execute if the pattern matches and the " "result of evaluating the guard expression is true." msgstr "" +"``body`` 包含一個節點串列,如果模式匹配並且為防護運算式 (guard expression) 的" +"求值 (evaluate) 結果為真,則會執行該節點串列。" #: ../../library/ast.rst:1470 msgid "" @@ -729,6 +899,8 @@ msgid "" "match statement documentation. This pattern succeeds if the match subject is " "equal to the evaluated value." msgstr "" +"以相等性進行比較的匹配文本或值的模式。``value`` 是一個運算式節點。允許值節點" +"受到匹配陳述式文件中所述的限制。如果匹配主題等於求出值,則此模式成功。" #: ../../library/ast.rst:1499 msgid "" @@ -736,6 +908,9 @@ msgid "" "singleton to be compared against: ``None``, ``True``, or ``False``. This " "pattern succeeds if the match subject is the given constant." msgstr "" +"按識別性 (identity) 進行比較的匹配文本模式。``value`` 是要與 ``None``、" +"``True`` 或 ``False`` 進行比較的單例 (singleton)。如果匹配主題是給定的常數," +"則此模式成功。" #: ../../library/ast.rst:1526 msgid "" @@ -744,6 +919,8 @@ msgid "" "variable length sequence if one of the subpatterns is a ``MatchStar`` node, " "otherwise matches a fixed length sequence." msgstr "" +"匹配序列模式。如果主題是一個序列,``patterns`` 包含與主題元素匹配的模式。如果" +"子模式之一是 ``MatchStar`` 節點,則匹配可變長度序列,否則匹配固定長度序列。" #: ../../library/ast.rst:1559 msgid "" @@ -752,6 +929,8 @@ msgid "" "sequence elements is bound to that name if the overall sequence pattern is " "successful." msgstr "" +"以可變長度匹配序列模式匹配序列的其餘部分。如果 ``name`` 不是 ``None``,則如果" +"整體序列模式成功,則包含其餘序列元素的串列將綁定到該名稱。" #: ../../library/ast.rst:1601 msgid "" @@ -761,6 +940,9 @@ msgid "" "elements. Permitted key expressions are restricted as described in the match " "statement documentation." msgstr "" +"匹配對映模式。``keys`` 是運算式節點的序列。``patterns`` 是相應的模式節點序" +"列。``rest`` 是一個可選名稱,可以指定它來捕獲剩餘的對映元素。允許的鍵運算式受" +"到匹配陳述式文件中所述的限制。" #: ../../library/ast.rst:1607 msgid "" @@ -770,6 +952,9 @@ msgid "" "dict containing the remaining mapping elements is bound to that name if the " "overall mapping pattern is successful." msgstr "" +"如果主題是對映,所有求值出的鍵運算式都存在於對映中,並且與每個鍵對應的值與相" +"應的子模式匹配,則此模式成功。如果 ``rest`` 不是 ``None``,則如果整體對映模式" +"成功,則包含其餘對映元素的字典將綁定到該名稱。" #: ../../library/ast.rst:1649 msgid "" @@ -781,6 +966,10 @@ msgid "" "the corresponding patterns (specified as keyword values in the class " "pattern)." msgstr "" +"匹配類別模式。``cls`` 是一個給定要匹配的名義類別 (nominal class) 的運算式。" +"``patterns`` 是要與類定義的模式匹配屬性序列進行匹配的模式節點序列。" +"``kwd_attrs`` 是要匹配的附加屬性序列(在類別模式中指定為關鍵字引數)," +"``kwd_patterns`` 是相應的模式(在類別模式中指定為關鍵字的值)。" #: ../../library/ast.rst:1656 msgid "" @@ -788,6 +977,8 @@ msgid "" "all positional patterns match the corresponding class-defined attributes, " "and any specified keyword attributes match their corresponding pattern." msgstr "" +"如果主題是指定類別的實例,所有位置模式都與相應的類別定義屬性匹配,並且任何指" +"定的關鍵字屬性與其相應模式匹配,則此模式成功。" #: ../../library/ast.rst:1660 msgid "" @@ -795,6 +986,8 @@ msgid "" "pattern node against the instance being matched. Several builtin types are " "also matched that way, as described in the match statement documentation." msgstr "" +"注意:類別可以定義一個回傳 self 的特性 (property),以便將模式節點與正在匹配的" +"實例進行匹配。一些內建型別也以這種方式匹配,如同匹配陳述式文件中所述。" #: ../../library/ast.rst:1715 msgid "" @@ -803,6 +996,9 @@ msgid "" "pattern is ``None``, the node represents a capture pattern (i.e a bare name) " "and will always succeed." msgstr "" +"匹配的 「as 模式 (as-pattern)」,為捕獲模式 (capture pattern) 或通配模式 " +"(wildcard pattern)。``pattern`` 包含主題將與之匹配的匹配模式。如果模式為 " +"``None``,則該節點代表捕獲模式(即裸名 (bare name))並且始終會成功。" #: ../../library/ast.rst:1720 msgid "" @@ -810,6 +1006,8 @@ msgid "" "is successful. If ``name`` is ``None``, ``pattern`` must also be ``None`` " "and the node represents the wildcard pattern." msgstr "" +"``name`` 屬性包含模式成功時將綁定的名稱。如果 ``name`` 為 ``None``,則 " +"``pattern`` 也必須為 ``None``,並且節點代表通配模式。" #: ../../library/ast.rst:1758 msgid "" @@ -819,16 +1017,19 @@ msgid "" "``patterns`` attribute contains a list of match pattern nodes that will be " "matched against the subject." msgstr "" +"匹配的 「or 模式 (or-pattern)」。 or 模式依次將其每個子模式與主題進行匹配,直" +"到成功為止,然後 or 模式就會被認為是成功的。如果沒有一個子模式成功,則 or 模" +"式將失敗。 ``patterns`` 屬性包含將與主題進行匹配的匹配模式節點串列。" #: ../../library/ast.rst:1793 msgid "Type parameters" -msgstr "" +msgstr "型別參數 (type parameters)" #: ../../library/ast.rst:1795 msgid "" ":ref:`Type parameters ` can exist on classes, functions, and " "type aliases." -msgstr "" +msgstr ":ref:`型別參數 `\\ 可以存在於類別、函式和型別別名上。" #: ../../library/ast.rst:1800 msgid "" @@ -836,84 +1037,97 @@ msgid "" "``bound`` is the bound or constraints, if any. If ``bound`` is a :class:" "`Tuple`, it represents constraints; otherwise it represents the bound." msgstr "" +"一個 :class:`typing.TypeVar`。``name`` 是型別變數的名稱。``bound`` 是(如果有" +"存在的)界限 (bound) 或約束 (constraint)。如果 ``bound`` 是一個 :class:" +"`Tuple`,它代表約束;否則它代表界限。" #: ../../library/ast.rst:1825 msgid "" "A :class:`typing.ParamSpec`. ``name`` is the name of the parameter " "specification." -msgstr "" +msgstr "A :class:`typing.ParamSpec`。``name`` 是參數規範的名稱。" #: ../../library/ast.rst:1850 msgid "" "A :class:`typing.TypeVarTuple`. ``name`` is the name of the type variable " "tuple." -msgstr "" +msgstr "一個 :class:`typing.TypeVarTuple`。``name`` 是型別變數元組的名稱。" #: ../../library/ast.rst:1875 msgid "Function and class definitions" -msgstr "" +msgstr "函式和類別定義" #: ../../library/ast.rst:1879 msgid "A function definition." -msgstr "" +msgstr "一個函式定義。" #: ../../library/ast.rst:1881 msgid "``name`` is a raw string of the function name." -msgstr "" +msgstr "``name`` 是函式名稱的原始字串。" #: ../../library/ast.rst:1882 msgid "``args`` is an :class:`arguments` node." -msgstr "" +msgstr "``args`` 是一個 :class:`arguments` 節點。" #: ../../library/ast.rst:1883 msgid "``body`` is the list of nodes inside the function." -msgstr "" +msgstr "``body`` 是函式內節點的串列。" #: ../../library/ast.rst:1884 msgid "" "``decorator_list`` is the list of decorators to be applied, stored outermost " "first (i.e. the first in the list will be applied last)." msgstr "" +"``decorator_list`` 是要應用的裝飾器串列,在最外層者會被儲存在首位(即串列中首" +"位將會是最後一個被應用的那個)。" #: ../../library/ast.rst:1886 msgid "``returns`` is the return annotation." -msgstr "" +msgstr "``returns`` 是回傳註釋。" #: ../../library/ast.rst:1887 ../../library/ast.rst:2065 msgid "``type_params`` is a list of :ref:`type parameters `." -msgstr "" +msgstr "``type_params`` 是\\ :ref:`型別參數 `\\ 的串列。" #: ../../library/ast.rst:1893 ../../library/ast.rst:2094 #: ../../library/ast.rst:2105 +#, fuzzy msgid "Added ``type_params``." -msgstr "" +msgstr "新增了“type_params”。" #: ../../library/ast.rst:1899 msgid "" "``lambda`` is a minimal function definition that can be used inside an " "expression. Unlike :class:`FunctionDef`, ``body`` holds a single node." msgstr "" +"``lambda`` 是可以在運算式內使用的最小函式定義。與 :class:`FunctionDef` 不同," +"``body`` 持有單個節點。" #: ../../library/ast.rst:1923 msgid "The arguments for a function." -msgstr "" +msgstr "函式的引數。" #: ../../library/ast.rst:1925 msgid "" "``posonlyargs``, ``args`` and ``kwonlyargs`` are lists of :class:`arg` nodes." msgstr "" +"``posonlyargs``、``args`` 和 ``kwonlyargs`` 是 :class:`arg` 節點的串列。" #: ../../library/ast.rst:1926 msgid "" "``vararg`` and ``kwarg`` are single :class:`arg` nodes, referring to the " "``*args, **kwargs`` parameters." msgstr "" +"``vararg`` 和 ``kwarg`` 是單個 :class:`arg` 節點,指的是 ``*args, **kwargs`` " +"參數。" #: ../../library/ast.rst:1928 msgid "" "``kw_defaults`` is a list of default values for keyword-only arguments. If " "one is ``None``, the corresponding argument is required." msgstr "" +"``kw_defaults`` 是僅限關鍵字引數的預設值串列。如果其中某個為 ``None``,則相應" +"參數就會是必要的。" #: ../../library/ast.rst:1930 msgid "" @@ -921,6 +1135,8 @@ msgid "" "positionally. If there are fewer defaults, they correspond to the last n " "arguments." msgstr "" +"``defaults`` 是可以按位置傳遞的引數的預設值串列。如果預設值較少,則它們對應於" +"最後 n 個引數。" #: ../../library/ast.rst:1937 msgid "" @@ -928,15 +1144,17 @@ msgid "" "``annotation`` is its annotation, such as a :class:`Str` or :class:`Name` " "node." msgstr "" +"串列中的單個引數。``arg`` 是引數名稱的原始字串,``annotation`` 是它的註釋,例" +"如 :class:`Str` 或 :class:`Name` 節點。" #: ../../library/ast.rst:1943 msgid "" "``type_comment`` is an optional string with the type annotation as a comment" -msgstr "" +msgstr "``type_comment`` 是一個可選字串,其註解為型別註釋" #: ../../library/ast.rst:1988 msgid "A ``return`` statement." -msgstr "" +msgstr "一個 ``return`` 陳述式。" #: ../../library/ast.rst:2003 msgid "" @@ -944,23 +1162,25 @@ msgid "" "they must be wrapped in a :class:`Expr` node if the value sent back is not " "used." msgstr "" +"一個 ``yield`` 或 ``yield from`` 運算式。因為這些是運算式,所以如果不使用發送" +"回來的值,則必須將它們包裝在 :class:`Expr` 節點中。" #: ../../library/ast.rst:2028 msgid "" "``global`` and ``nonlocal`` statements. ``names`` is a list of raw strings." -msgstr "" +msgstr "``global`` 和 ``nonlocal`` 陳述式。``names`` 是原始字串的串列。" #: ../../library/ast.rst:2055 msgid "A class definition." -msgstr "" +msgstr "一個類別定義。" #: ../../library/ast.rst:2057 msgid "``name`` is a raw string for the class name" -msgstr "" +msgstr "``name`` 是類別名的原始字串" #: ../../library/ast.rst:2058 msgid "``bases`` is a list of nodes for explicitly specified base classes." -msgstr "" +msgstr "``bases`` 是被顯式指定的基底類別節點串列。" #: ../../library/ast.rst:2059 msgid "" @@ -968,32 +1188,37 @@ msgid "" "'metaclass'. Other keywords will be passed to the metaclass, as per " "`PEP-3115 `_." msgstr "" +"``keywords`` 是一個 :class:`keyword` 節點的串列,主要用於 'metaclass'(元類" +"別)。如 `PEP-3115 `_ 所述,其他關鍵字將被" +"傳遞到 metaclass。" #: ../../library/ast.rst:2062 msgid "" "``body`` is a list of nodes representing the code within the class " "definition." -msgstr "" +msgstr "``body`` 是表示類別定義中程式碼的節點串列。" #: ../../library/ast.rst:2064 msgid "``decorator_list`` is a list of nodes, as in :class:`FunctionDef`." -msgstr "" +msgstr "``decorator_list`` 是一個節點串列,如 :class:`FunctionDef` 中所示。" #: ../../library/ast.rst:2098 msgid "Async and await" -msgstr "" +msgstr "async 和 await" #: ../../library/ast.rst:2102 msgid "" "An ``async def`` function definition. Has the same fields as :class:" "`FunctionDef`." -msgstr "" +msgstr "一個 ``async def`` 函式定義。與 :class:`FunctionDef` 具有相同的欄位。" #: ../../library/ast.rst:2111 msgid "" "An ``await`` expression. ``value`` is what it waits for. Only valid in the " "body of an :class:`AsyncFunctionDef`." msgstr "" +"一個 ``await`` 運算式。``value`` 是它等待的東西。僅在 :class:" +"`AsyncFunctionDef` 主體 (body) 中有效。" #: ../../library/ast.rst:2145 msgid "" @@ -1001,6 +1226,8 @@ msgid "" "fields as :class:`For` and :class:`With`, respectively. Only valid in the " "body of an :class:`AsyncFunctionDef`." msgstr "" +"``async for`` 迴圈和 ``async with`` 情境管理器。它們分別具有與 :class:`For` " +"和 :class:`With` 相同的欄位。僅在 :class:`AsyncFunctionDef` 主體中有效。" #: ../../library/ast.rst:2150 msgid "" @@ -1010,22 +1237,30 @@ msgid "" "singletons. Changes to one will be reflected in all other occurrences of the " "same value (e.g. :class:`ast.Add`)." msgstr "" +"當字串被 :func:`ast.parse` 剖析時,回傳樹的運算子節點(\\ :class:`ast." +"operator`、:class:`ast.unaryop`、:class:`ast.cmpop`、:class: :class:`ast." +"boolop` 和 :class:`ast.expr_context`\\ )將是單例。對其中之一的更改將反映在所" +"有其他出現的相同值中(例如 :class:`ast.Add`\\ )。" #: ../../library/ast.rst:2158 msgid ":mod:`ast` Helpers" -msgstr "" +msgstr ":mod:`ast` 輔助程式" #: ../../library/ast.rst:2160 msgid "" "Apart from the node classes, the :mod:`ast` module defines these utility " "functions and classes for traversing abstract syntax trees:" msgstr "" +"除了節點類別之外,:mod:`ast` 模組還定義了這些用於遍歷 (traverse) 抽象語法樹的" +"實用函式和類別:" #: ../../library/ast.rst:2165 msgid "" "Parse the source into an AST node. Equivalent to ``compile(source, " "filename, mode, ast.PyCF_ONLY_AST)``." msgstr "" +"將原始碼剖析為 AST 節點。相當於 ``compile(source, filename, mode, ast." +"PyCF_ONLY_AST)``。" #: ../../library/ast.rst:2168 msgid "" @@ -1039,6 +1274,12 @@ msgid "" "the ``type_ignores`` attribute of :class:`Module` (otherwise it is always an " "empty list)." msgstr "" +"如果給定 ``type_comments=True``,剖析器將被修改為檢查並回傳 :pep:`484` 和 :" +"pep:`526` 指定的型別註釋。這相當於將 :data:`ast.PyCF_TYPE_COMMENTS` 新增到傳" +"遞給 :func:`compile()` 的旗標中。這將報告錯誤型別註釋的語法錯誤。如果沒有此旗" +"標,型別註釋將被忽略,並且所選 AST 節點上的 ``type_comment`` 欄位將始終為 " +"``None``。此外,``# type: ignore`` 註釋的位置將作為 :class:`Module` 的 " +"``type_ignores`` 屬性回傳(否則它始終是一個空串列)。" #: ../../library/ast.rst:2178 msgid "" @@ -1046,6 +1287,9 @@ msgid "" "correspond to :pep:`484` \"signature type comments\", e.g. ``(str, int) -> " "List[str]``." msgstr "" +"此外,如果 ``mode`` 是 ``'func_type'``,則輸入語法將會依據 :pep:`484`\\ 「簽" +"名型別註解 (signature type comments)」而被修改,例如 ``(str, int) -> " +"List[str]``。" #: ../../library/ast.rst:2182 msgid "" @@ -1055,11 +1299,15 @@ msgid "" "use of ``async`` and ``await`` as variable names. The lowest supported " "version is ``(3, 4)``; the highest is ``sys.version_info[0:2]``." msgstr "" +"此外,將 ``feature_version`` 設定為元組 ``(major, minor)`` 將嘗試使用該 " +"Python 版本的文法進行剖析。當前 ``major`` 必須等於 ``3``。例如,設定 " +"``feature_version=(3, 4)`` 將允許使用 ``async`` 和 ``await`` 作為變數名稱。有" +"支援的最低版本是 ``(3, 4)``;最高的是 ``sys.version_info[0:2]``。" #: ../../library/ast.rst:2189 msgid "" "If source contains a null character ('\\0'), :exc:`ValueError` is raised." -msgstr "" +msgstr "如果來源包含 null 字元 ('\\0'),則會引發 :exc:`ValueError`。" #: ../../library/ast.rst:2192 msgid "" @@ -1070,24 +1318,29 @@ msgid "" "node for a return statement, but it cannot be compiled alone (it needs to be " "inside a function node)." msgstr "" +"請注意,成功將原始碼剖析為 AST 物件並不能保證提供的原始碼是可以執行的有效 " +"Python 程式碼,因為編譯步驟可能會引發進一步的 :exc:`SyntaxError` 例外。例如," +"原始的 ``return 42`` 為 return 陳述式生成一個有效的 AST 節點,但它不能單獨編" +"譯(它需要位於函式節點內)。" #: ../../library/ast.rst:2199 msgid "" "In particular, :func:`ast.parse` won't do any scoping checks, which the " "compilation step does." msgstr "" +"特別是 :func:`ast.parse` 不會執行任何範圍檢查,而編譯步驟才會執行此操作。" #: ../../library/ast.rst:2203 msgid "" "It is possible to crash the Python interpreter with a sufficiently large/" "complex string due to stack depth limitations in Python's AST compiler." msgstr "" +"由於 Python AST 編譯器中的堆疊 (stack) 深度限制,太大或太複雜的字串可能會導" +"致 Python 直譯器崩潰。" #: ../../library/ast.rst:2207 msgid "Added ``type_comments``, ``mode='func_type'`` and ``feature_version``." -msgstr "" -"新增 ``type_comments``\\ 、\\ ``mode='func_type'`` 與 " -"``feature_version``\\ 。" +msgstr "新增 ``type_comments``、``mode='func_type'`` 與 ``feature_version``。" #: ../../library/ast.rst:2213 msgid "" @@ -1095,6 +1348,8 @@ msgid "" "would produce an equivalent :class:`ast.AST` object if parsed back with :" "func:`ast.parse`." msgstr "" +"反剖析 :class:`ast.AST` 物件並生成一個帶有程式碼的字串,如果使用 :func:`ast." +"parse` 剖析回來,該程式碼將生成等效的 :class:`ast.AST` 物件。" #: ../../library/ast.rst:2218 msgid "" @@ -1102,12 +1357,14 @@ msgid "" "that generated the :class:`ast.AST` object (without any compiler " "optimizations, such as constant tuples/frozensets)." msgstr "" +"生成的程式碼字串不一定等於生成 :class:`ast.AST` 物件的原始程式碼(沒有任何編" +"譯器最佳化,例如常數元組/凍結集合)。" #: ../../library/ast.rst:2223 msgid "" "Trying to unparse a highly complex expression would result with :exc:" "`RecursionError`." -msgstr "" +msgstr "嘗試剖析高度複雜的運算式會導致 :exc:`RecursionError`。" #: ../../library/ast.rst:2231 msgid "" @@ -1116,6 +1373,9 @@ msgid "" "following Python literal structures: strings, bytes, numbers, tuples, lists, " "dicts, sets, booleans, ``None`` and ``Ellipsis``." msgstr "" +"為僅包含 Python 文本或容器之顯示的運算式節點或字串來求值。提供的字串或節點只" +"能包含以下 Python 文本結構:字串、位元組、數字、元組、串列、字典、集合、布林" +"值、``None`` 和 ``Ellipsis``。" #: ../../library/ast.rst:2236 msgid "" @@ -1123,6 +1383,8 @@ msgid "" "need to parse the values oneself. It is not capable of evaluating " "arbitrarily complex expressions, for example involving operators or indexing." msgstr "" +"這可用於為包含 Python 值的字串求值,而無需自己剖析這些值。它無法計算任意複雜" +"的運算式,例如涉及運算子或索引。" #: ../../library/ast.rst:2241 msgid "" @@ -1135,30 +1397,37 @@ msgid "" "excessive CPU consumption denial of service on some inputs. Calling it on " "untrusted data is thus not recommended." msgstr "" +"該函式過去被記錄為「安全」,但沒有定義其含義,這有點誤導讀者,它是特別設計為" +"不去執行 Python 程式碼,與更通用的 :func:`eval` 不同。沒有命名空間、沒有名稱" +"查找、也沒有呼叫的能力。但它也不能免受攻擊:相對較小的輸入可能會導致記憶體耗" +"盡或 C 堆疊耗盡,從而導致行程崩潰。某些輸入也可能會出現 CPU 消耗過多而導致拒" +"絕服務的情況。因此不建議在不受信任的資料上呼叫它。" #: ../../library/ast.rst:2251 msgid "" "It is possible to crash the Python interpreter due to stack depth " "limitations in Python's AST compiler." -msgstr "" +msgstr "由於 Python AST 編譯器的堆疊深度限制,Python 直譯器可能會崩潰。" #: ../../library/ast.rst:2254 msgid "" "It can raise :exc:`ValueError`, :exc:`TypeError`, :exc:`SyntaxError`, :exc:" "`MemoryError` and :exc:`RecursionError` depending on the malformed input." msgstr "" +"它可能會引發 :exc:`ValueError`、:exc:`TypeError`、:exc:`SyntaxError`、:exc:" +"`MemoryError` 和 :exc:`RecursionError`,具體取決於格式錯誤的輸入。" #: ../../library/ast.rst:2258 msgid "Now allows bytes and set literals." -msgstr "" +msgstr "現在允許位元組和設定文本。" #: ../../library/ast.rst:2261 msgid "Now supports creating empty sets with ``'set()'``." -msgstr "" +msgstr "現在支援使用 ``'set()'`` 建立空集合。" #: ../../library/ast.rst:2264 msgid "For string inputs, leading spaces and tabs are now stripped." -msgstr "" +msgstr "對於字串輸入,前導空格和定位字元 (tab) 現在已被去除。" #: ../../library/ast.rst:2270 msgid "" @@ -1167,10 +1436,14 @@ msgid "" "`Module` node), or ``None`` if it has no docstring. If *clean* is true, " "clean up the docstring's indentation with :func:`inspect.cleandoc`." msgstr "" +"回傳給定 *node* 的文件字串 (docstring)(必須是 :class:`FunctionDef`、:class:" +"`AsyncFunctionDef`、:class:`ClassDef` 或 :class:`Module` 節點)或如果它沒有文" +"件字串則為 ``None``。如果 *clean* 為 true,則使用 :func:`inspect.cleandoc` 清" +"理文件字串的縮排。" #: ../../library/ast.rst:2276 msgid ":class:`AsyncFunctionDef` is now supported." -msgstr "目前已支援 :class:`AsyncFunctionDef`\\ 。" +msgstr "目前已支援 :class:`AsyncFunctionDef`。" #: ../../library/ast.rst:2282 msgid "" @@ -1178,12 +1451,17 @@ msgid "" "location information (:attr:`lineno`, :attr:`end_lineno`, :attr:" "`col_offset`, or :attr:`end_col_offset`) is missing, return ``None``." msgstr "" +"獲取生成 *node* 的 *source* 的原始碼片段。如果某些位置資訊(:attr:`lineno`、:" +"attr:`end_lineno`、:attr:`col_offset` 或 :attr:`end_col_offset`\\ )丟失,則" +"回傳 ``None``。" #: ../../library/ast.rst:2286 msgid "" "If *padded* is ``True``, the first line of a multi-line statement will be " "padded with spaces to match its original position." msgstr "" +"如果 *padded* 為 ``True``,則多列陳述式的第一列將用空格填充 (padded) 以匹配其" +"原始位置。" #: ../../library/ast.rst:2294 msgid "" @@ -1193,6 +1471,10 @@ msgid "" "adds these attributes recursively where not already set, by setting them to " "the values of the parent node. It works recursively starting at *node*." msgstr "" +"當你使用 :func:`compile` 編譯節點樹時,編譯器預期支援它們的每個節點都有 :" +"attr:`lineno` 和 :attr:`col_offset` 屬性。填入生成的節點相當繁瑣,因此該輔助" +"工具透過將這些屬性設定為父節點的值,在尚未設定的地方遞迴地新增這些屬性。它從 " +"*node* 開始遞迴地工作。" #: ../../library/ast.rst:2303 msgid "" @@ -1200,6 +1482,8 @@ msgid "" "starting at *node* by *n*. This is useful to \"move code\" to a different " "location in a file." msgstr "" +"將樹中從 *node* 開始的每個節點的列號和結束列號增加 *n*。這對於「移動程式碼」" +"到檔案中的不同位置很有用。" #: ../../library/ast.rst:2310 msgid "" @@ -1207,18 +1491,25 @@ msgid "" "`end_lineno`, and :attr:`end_col_offset`) from *old_node* to *new_node* if " "possible, and return *new_node*." msgstr "" +"如果可行,將原始位置(:attr:`lineno`、:attr:`col_offset`、:attr:`end_lineno` " +"和 :attr:`end_col_offset` )從 *old_node* 複製到 *new_node*,並回傳 " +"*new_node* 。" #: ../../library/ast.rst:2317 msgid "" "Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields`` " "that is present on *node*." msgstr "" +"為 *node* 上存在的 ``node._fields`` 中的每個欄位生成一個 ``(fieldname, " +"value)`` 元組。" #: ../../library/ast.rst:2323 msgid "" "Yield all direct child nodes of *node*, that is, all fields that are nodes " "and all items of fields that are lists of nodes." msgstr "" +"生成 *node* 的所有直接子節點,即作為節點的所有欄位以及作為節點串列欄位的所有" +"項目。" #: ../../library/ast.rst:2329 msgid "" @@ -1226,6 +1517,8 @@ msgid "" "(including *node* itself), in no specified order. This is useful if you " "only want to modify nodes in place and don't care about the context." msgstr "" +"遞迴地生成樹中從 *node* 開始的所有後代節點(包括 *node* 本身),不按指定順" +"序。如果你只想就地修改節點而不關心情境,這非常有用。" #: ../../library/ast.rst:2336 msgid "" @@ -1233,12 +1526,14 @@ msgid "" "visitor function for every node found. This function may return a value " "which is forwarded by the :meth:`visit` method." msgstr "" +"節點訪問者基底類別,它遍歷抽象語法樹並為找到的每個節點呼叫訪問者函式。該函式" +"可能會回傳一個由 :meth:`visit` 方法轉發的值。" #: ../../library/ast.rst:2340 msgid "" "This class is meant to be subclassed, with the subclass adding visitor " "methods." -msgstr "" +msgstr "這個類別應該被子類別化,子類別新增訪問者方法。" #: ../../library/ast.rst:2345 msgid "" @@ -1246,16 +1541,21 @@ msgid "" "`self.visit_{classname}` where *classname* is the name of the node class, " "or :meth:`generic_visit` if that method doesn't exist." msgstr "" +"訪問一個節點。預設實作呼叫名為 :samp:`self.visit_{classname}` 的方法,其中 " +"*classname* 是節點類別的名稱,或者在該方法不存在時呼叫 :meth:" +"`generic_visit`。" #: ../../library/ast.rst:2351 msgid "This visitor calls :meth:`visit` on all children of the node." -msgstr "" +msgstr "該訪問者對該節點的所有子節點呼叫 :meth:`visit`。" #: ../../library/ast.rst:2353 msgid "" "Note that child nodes of nodes that have a custom visitor method won't be " "visited unless the visitor calls :meth:`generic_visit` or visits them itself." msgstr "" +"請注意,除非訪問者呼叫 :meth:`generic_visit` 或訪問它們本身,否則不會訪問具有" +"自定義訪問者方法的節點之子節點。" #: ../../library/ast.rst:2357 msgid "" @@ -1263,6 +1563,9 @@ msgid "" "during traversal. For this a special visitor exists (:class:" "`NodeTransformer`) that allows modifications." msgstr "" +"如果你想在遍歷期間將變更應用 (apply) 於節點,請不要使用 :class:" +"`NodeVisitor`。為此,有個允許修改的特殊遍歷訪問者工具 :class:" +"`NodeTransformer`。" #: ../../library/ast.rst:2363 msgid "" @@ -1271,12 +1574,15 @@ msgid "" "not be called in future Python versions. Add the :meth:`visit_Constant` " "method to handle all constant nodes." msgstr "" +":meth:`visit_Num`、:meth:`visit_Str`、:meth:`visit_Bytes`、:meth:" +"`visit_NameConstant` 和 :meth:`visit_Ellipsis` 方法現已棄用,並且不會在未來的" +"Python 版本中被呼叫。新增 :meth:`visit_Constant` 方法來處理所有常數節點。" #: ../../library/ast.rst:2371 msgid "" "A :class:`NodeVisitor` subclass that walks the abstract syntax tree and " "allows modification of nodes." -msgstr "" +msgstr "一個 :class:`NodeVisitor` 子類別,它會遍歷抽象語法樹並允許修改節點。" #: ../../library/ast.rst:2374 msgid "" @@ -1286,12 +1592,17 @@ msgid "" "location, otherwise it is replaced with the return value. The return value " "may be the original node in which case no replacement takes place." msgstr "" +":class:`NodeTransformer` 將遍歷 AST 並使用訪問者方法的回傳值來替換或刪除舊節" +"點。如果訪問者方法的回傳值為 ``None``,則該節點將從其位置中刪除,否則將被替換" +"為回傳值。回傳值可能是原始節點,在這種情況下不會發生替換。" #: ../../library/ast.rst:2380 msgid "" "Here is an example transformer that rewrites all occurrences of name lookups " "(``foo``) to ``data['foo']``::" msgstr "" +"下面是一個示範用的 transformer,它將查找所有出現名稱 (``foo``) 並改寫為 " +"``data['foo']``: ::" #: ../../library/ast.rst:2392 msgid "" @@ -1299,6 +1610,8 @@ msgid "" "either transform the child nodes yourself or call the :meth:`generic_visit` " "method for the node first." msgstr "" +"請記住,如果你正在操作的節點有子節點,你必須自己轉換子節點或首先呼叫該節點" +"的 :meth:`generic_visit` 方法。" #: ../../library/ast.rst:2396 msgid "" @@ -1306,6 +1619,8 @@ msgid "" "statement nodes), the visitor may also return a list of nodes rather than " "just a single node." msgstr "" +"對於屬於陳述式總集 (collection) 一部分的節點(適用於所有陳述式節點),訪問者" +"還可以回傳節點串列,而不僅僅是單個節點。" #: ../../library/ast.rst:2400 msgid "" @@ -1314,10 +1629,13 @@ msgid "" "`lineno`), :func:`fix_missing_locations` should be called with the new sub-" "tree to recalculate the location information::" msgstr "" +"如果 :class:`NodeTransformer` 引進了新節點(不屬於原始樹的一部分),但沒有給" +"它們提供位置資訊(例如 :attr:`lineno`\\ ),則應使用新的子節點呼叫 :func:" +"`fix_missing_locations` 樹重新計算位置資訊: ::" #: ../../library/ast.rst:2408 msgid "Usually you use the transformer like this::" -msgstr "" +msgstr "你通常會像這樣使用 transformer: ::" #: ../../library/ast.rst:2415 msgid "" @@ -1329,6 +1647,11 @@ msgid "" "dumped by default. If this is wanted, *include_attributes* can be set to " "true." msgstr "" +"回傳 *node* 中樹的格式化轉儲 (formatted dump),這主要用於除錯。如果 " +"*annotate_fields* 為 true(為預設值),則回傳的字串將顯示欄位的名稱和值。如" +"果 *annotate_fields* 為 false,則透過省略明確的欄位名稱,結果字串將更加縮減簡" +"潔。預設情況下,不會轉儲列號和行偏移量等屬性。如果需要,可以設定 " +"*include_attributes* 為 true。" #: ../../library/ast.rst:2423 msgid "" @@ -1339,6 +1662,10 @@ msgid "" "many spaces per level. If *indent* is a string (such as ``\"\\t\"``), that " "string is used to indent each level." msgstr "" +"如果 *indent* 是非負整數或字串,那麼樹將使用該縮排級別來做漂亮印出 (pretty-" +"print)。縮排級別 0、負數或 ``\"\"`` 只會插入換列符號 (newlines)。``None``\\ " +"(預設值)代表選擇單列表示。使用正整數縮排可以在每個級別縮排相同數量的空格。" +"如果 *indent* 是一個字串(例如 ``\"\\t\"``\\ ),則該字串用於縮排每個級別。" #: ../../library/ast.rst:2430 msgid "Added the *indent* option." @@ -1346,79 +1673,87 @@ msgstr "新增 *indent* 選項。" #: ../../library/ast.rst:2437 msgid "Compiler Flags" -msgstr "" +msgstr "編譯器旗標" #: ../../library/ast.rst:2439 msgid "" "The following flags may be passed to :func:`compile` in order to change " "effects on the compilation of a program:" -msgstr "" +msgstr "可以將以下旗標傳遞給 :func:`compile` 以變更對程式的編譯效果:" #: ../../library/ast.rst:2444 msgid "" "Enables support for top-level ``await``, ``async for``, ``async with`` and " "async comprehensions." msgstr "" +"啟用對最高階 ``await``、``async for``、``async with`` 和非同步綜合運算的支" +"援。" #: ../../library/ast.rst:2451 msgid "" "Generates and returns an abstract syntax tree instead of returning a " "compiled code object." -msgstr "" +msgstr "生成並回傳抽象語法樹,而不是回傳已編譯的程式碼物件。" #: ../../library/ast.rst:2456 msgid "" "Enables support for :pep:`484` and :pep:`526` style type comments (``# type: " "``, ``# type: ignore ``)." msgstr "" +"啟用對 :pep:`484` 和 :pep:`526` 樣式型別註釋的支援 (``# type: ``, ``# " +"type: ignore ``)。" #: ../../library/ast.rst:2465 msgid "Command-Line Usage" -msgstr "" +msgstr "命令列用法" #: ../../library/ast.rst:2469 msgid "" "The :mod:`ast` module can be executed as a script from the command line. It " "is as simple as:" -msgstr "" +msgstr ":mod:`ast` 模組可以作為腳本從命令列執行,可以像這樣簡單地做到:" #: ../../library/ast.rst:2476 msgid "The following options are accepted:" -msgstr "" +msgstr "以下選項可被接受:" #: ../../library/ast.rst:2482 msgid "Show the help message and exit." -msgstr "" +msgstr "顯示幫助訊息並退出。" #: ../../library/ast.rst:2487 msgid "" "Specify what kind of code must be compiled, like the *mode* argument in :" "func:`parse`." -msgstr "" +msgstr "指定必須編譯哪種類型的程式碼,像是 :func:`parse` 中的 *mode* 引數。" #: ../../library/ast.rst:2492 msgid "Don't parse type comments." -msgstr "" +msgstr "不要剖析型別註解。" #: ../../library/ast.rst:2496 msgid "Include attributes such as line numbers and column offsets." -msgstr "" +msgstr "包括列號和行偏移量等屬性。" #: ../../library/ast.rst:2501 msgid "Indentation of nodes in AST (number of spaces)." -msgstr "" +msgstr "AST 中節點的縮進(空格數)。" #: ../../library/ast.rst:2503 msgid "" "If :file:`infile` is specified its contents are parsed to AST and dumped to " "stdout. Otherwise, the content is read from stdin." msgstr "" +"如果指定了 :file:`infile`,則其內容將被剖析為 AST 並傾印 (dump) 到 stdout。否" +"則會從 stdin 讀取內容。" #: ../../library/ast.rst:2509 msgid "" "`Green Tree Snakes `_, an external " "documentation resource, has good details on working with Python ASTs." msgstr "" +"`Green Tree Snakes `_ 是一個外部文件" +"資源,提供了有關使用 Python AST 的詳細資訊。" #: ../../library/ast.rst:2512 msgid "" @@ -1427,6 +1762,9 @@ msgid "" "code that generated them. This is helpful for tools that make source code " "transformations." msgstr "" +"`ASTTokens `_ 使" +"用生成它們的原始碼中的標記和文本的位置來註釋 Python AST。這對於進行原始碼轉換" +"的工具很有幫助。" #: ../../library/ast.rst:2517 msgid "" @@ -1434,6 +1772,9 @@ msgid "" "token-based and parse-tree-based views of python programs by inserting two-" "way links between tokens and ast nodes." msgstr "" +"`leoAst.py `_ 透過在 token " +"和 ast 節點之間插入雙向鏈結,統一了 python 程式的基於 token 和基於剖析樹的視" +"圖。" #: ../../library/ast.rst:2521 msgid "" @@ -1441,6 +1782,9 @@ msgid "" "Tree that looks like an ast tree and keeps all formatting details. It's " "useful for building automated refactoring (codemod) applications and linters." msgstr "" +"`LibCST `_ 將程式碼剖析為具體語法樹 " +"(Concrete Syntax Tree),看起來像 ast 樹並保留所有格式詳細資訊。它對於建置自動" +"重構 (codemod) 應用程式和 linter 非常有用。" #: ../../library/ast.rst:2526 msgid "" @@ -1449,6 +1793,9 @@ msgid "" "multiple Python versions). Parso is also able to list multiple syntax errors " "in your python file." msgstr "" +"`Parso `_ 是一個 Python 剖析器,支援不同 " +"Python 版本的錯誤復原和往返剖析。Parso 還能夠列出 python 檔案中的多個語法錯" +"誤。" #: ../../library/ast.rst:59 msgid "? (question mark)" From ca8c60beaeaf381e8b18d97924d73fa6f5495450 Mon Sep 17 00:00:00 2001 From: "Wei-Hsiang (Matt) Wang" Date: Mon, 11 Dec 2023 17:55:01 +0800 Subject: [PATCH 2/7] Apply suggestions from code review Co-authored-by: Payon --- library/ast.po | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/library/ast.po b/library/ast.po index 7e9f51e462..fdd106af9c 100644 --- a/library/ast.po +++ b/library/ast.po @@ -32,9 +32,9 @@ msgid "" "with each Python release; this module helps to find out programmatically " "what the current grammar looks like." msgstr "" -":mod:`ast` 模組可以幫助 Python 應用程式處理 Python 抽象語法樹狀資料結構。抽象" -"語法本身可能會隨著每個 Python 版本發布而改變;此模組有助於以程式化的方式來得" -"知當前語法的面貌。" +":mod:`ast` 模組可以幫助 Python 應用程式處理 Python 抽象語法文法 (abstract " +"syntax grammar) 樹狀資料結構。抽象語法本身可能會隨著每個 Python 版本發布而改" +"變;此模組有助於以程式化的方式來得知當前文法的面貌。" #: ../../library/ast.rst:23 msgid "" @@ -83,8 +83,8 @@ msgid "" "rules with alternatives (aka \"sums\"), the left-hand side class is " "abstract: only instances of specific constructor nodes are ever created." msgstr "" -"抽象文法中為每個左側符號定義了一個類別(例如,:class:`ast.stmt` 或 :class:" -"`ast.expr`\\ )。另外,也為每個右側的建構函式 (constructor) 定義了一個類別;" +"抽象文法中為每個左側符號定義了一個類別(例如 :class:`ast.stmt` 或 :class:" +"`ast.expr`\\ )。此外,也為每個右側的建構函式 (constructor) 定義了一個類別;" "這些類別繼承自左側樹的類別。例如,:class:`ast.BinOp` 繼承自 :class:`ast." "expr`。對於具有替代方案(即為「和 (sums)」)的生產規則,左側類別是抽象的:僅" "有特定建構函式節點的實例會被建立。" @@ -141,7 +141,7 @@ msgid "" "one can get the source segment of a one-line expression node using " "``source_line[node.col_offset : node.end_col_offset]``." msgstr "" -"請注意,編譯器不需要知道結束位置,因此為可選的。結束偏移量在最後一個符號\\ *" +"請注意,編譯器並不需要結束位置,因此其為可選的。結束偏移量在最後一個符號\\ *" "之後*,例如可以使用 ``source_line[node.col_offset : node.end_col_offset]`` 來" "獲取單列運算式節點 (expression node) 的原始片段。" @@ -229,7 +229,7 @@ msgstr "" #: ../../library/ast.rst:160 msgid "*body* is a :class:`list` of the module's :ref:`ast-statements`." -msgstr "*body* 是模組的\\ :ref:`ast-statements` :class:`list`。" +msgstr "*body* 是模組的\\ :ref:`ast-statements` 的一個 :class:`list`。" #: ../../library/ast.rst:162 msgid "" @@ -244,14 +244,15 @@ msgid "" "A single Python :ref:`expression input `. Node type " "generated by :func:`ast.parse` when *mode* is ``\"eval\"``." msgstr "" -"單個 Python :ref:`運算式輸入 `,為當 *mode* 是 " -"``\"eval\"`` 時,:func:`ast.parse` 生成的節點型別。" +"單個 Python :ref:`運算式輸入 `。當 *mode* 是 ``\"eval\"`` " +"時節點型別由 :func:`ast.parse` 生成。" #: ../../library/ast.rst:182 msgid "" "*body* is a single node, one of the :ref:`expression types `." -msgstr "*body* 是單個節點,是\\ :ref:`運算式型別 `\\ 之一。" +msgstr "" +"*body* 是單個節點,是\\ :ref:`運算式型別 `\\ 的其中之一。" #: ../../library/ast.rst:194 msgid "" @@ -259,7 +260,7 @@ msgid "" "Node type generated by :func:`ast.parse` when *mode* is ``\"single\"``." msgstr "" "單個\\ :ref:`互動式輸入 `,和\\ :ref:`tut-interac`\\ 中所述的相" -"似。為當 *mode* 是 ``\"single\"`` 時 :func:`ast.parse` 生成的節點型別。" +"似。當 *mode* 是 ``\"single\"`` 時節點型別由 :func:`ast.parse` 生成。" #: ../../library/ast.rst:197 msgid "*body* is a :class:`list` of :ref:`statement nodes `." @@ -274,7 +275,7 @@ msgid "" "generated by :func:`ast.parse` when *mode* is ``\"func_type\"``." msgstr "" "函式的舊式型別註解的表示法,因為 3.5 之前的 Python 版本不支援 :pep:`484` 註" -"釋。當 *mode* 為 ``\"func_type\"`` 時 :func:`ast.parse` 產生的節點型別。" +"釋。當 *mode* 是 ``\"func_type\"`` 時節點型別由 :func:`ast.parse` 生成。" #: ../../library/ast.rst:220 msgid "Such type comments would look like this::" @@ -348,8 +349,8 @@ msgid "" "the value, or ``None`` if no format was specified. Both ``conversion`` and " "``format_spec`` can be set at the same time." msgstr "" -"``format_spec`` 是一個 :class:`JoinedStr` 節點,表示值的格式,``None`` 則代表" -"未指定格式。``conversion`` 和 ``format_spec`` 可以同時設定。" +"``format_spec`` 是一個 :class:`JoinedStr` 節點,表示值的格式,若未指定格式則" +"為 ``None``。``conversion`` 和 ``format_spec`` 可以同時設定。" #: ../../library/ast.rst:284 msgid "" @@ -533,7 +534,7 @@ msgid "" "An expression such as ``a if b else c``. Each field holds a single node, so " "in the following example, all three are :class:`Name` nodes." msgstr "" -"像是 ``a if b else c`` 之類的運算式。每個欄位都包含一個節點,因此在以下範例" +"像是 ``a if b else c`` 之類的運算式。每個欄位都保存一個節點,因此在以下範例" "中,所有三個都是 :class:`Name` 節點。" #: ../../library/ast.rst:636 @@ -580,8 +581,8 @@ msgid "" "occur only inside the *slice* field of :class:`Subscript`, either directly " "or as an element of :class:`Tuple`." msgstr "" -"常規切片(形式為 ``lower:upper`` 或 ``lower:upper:step``\\ )。只能直接出現" -"在 :class:`Subscript` 的 *slice* 欄位內,或者作為 :class:`Tuple` 的元素出現。" +"常規切片(形式為 ``lower:upper`` 或 ``lower:upper:step``\\ )。只能直接或者或" +"者作為 :class:`Tuple` 的元素出現在 :class:`Subscript` 的 *slice* 欄位內。" #: ../../library/ast.rst:714 msgid "Comprehensions" @@ -685,7 +686,7 @@ msgid "" "``raise``. ``cause`` is the optional part for ``y`` in ``raise x from y``." msgstr "" "一個 ``raise`` 陳述式。``exc`` 是要引發的例外物件,通常是 :class:`Call` 或 :" -"class:`Name`,或者獨立 ``raise`` 的則為 ``None``。``cause`` 是 ``raise x " +"class:`Name`,若是獨立的 ``raise`` 則為 ``None``。``cause`` 是 ``raise x " "from y`` 中的可選部分 ``y``。" #: ../../library/ast.rst:977 @@ -741,7 +742,7 @@ msgid "" "import (0 means absolute import)." msgstr "" "代表 ``from x import y``。``module`` 是 'from' 名稱的原始字串,前面沒有任何的" -"點 (dot),或者對於諸如 ``from . import foo`` 之類的陳述式為 ``None``。" +"點 (dot),或者對於諸如 ``from . import foo`` 之類的陳述式則為 ``None``。" "``level`` 是一個整數,保存相對引入的級別(0 表示絕對引入)。" #: ../../library/ast.rst:1089 @@ -865,7 +866,7 @@ msgid "" "iterable of :class:`match_case` nodes with the different cases." msgstr "" "一個 ``match`` 陳述式。``subject`` 保存匹配的主題(與案例匹配的物件)," -"``cases`` 包含具有不同案例的可疊代 :class:`match_case` 節點。" +"``cases`` 包含具有不同案例的 :class:`match_case` 節點的可疊代物件。" #: ../../library/ast.rst:1417 msgid "" @@ -967,7 +968,7 @@ msgid "" "pattern)." msgstr "" "匹配類別模式。``cls`` 是一個給定要匹配的名義類別 (nominal class) 的運算式。" -"``patterns`` 是要與類定義的模式匹配屬性序列進行匹配的模式節點序列。" +"``patterns`` 是要與類別定義的模式匹配屬性序列進行匹配的模式節點序列。" "``kwd_attrs`` 是要匹配的附加屬性序列(在類別模式中指定為關鍵字引數)," "``kwd_patterns`` 是相應的模式(在類別模式中指定為關鍵字的值)。" @@ -1101,7 +1102,7 @@ msgid "" "expression. Unlike :class:`FunctionDef`, ``body`` holds a single node." msgstr "" "``lambda`` 是可以在運算式內使用的最小函式定義。與 :class:`FunctionDef` 不同," -"``body`` 持有單個節點。" +"``body`` 保存單個節點。" #: ../../library/ast.rst:1923 msgid "The arguments for a function." @@ -1188,7 +1189,7 @@ msgid "" "'metaclass'. Other keywords will be passed to the metaclass, as per " "`PEP-3115 `_." msgstr "" -"``keywords`` 是一個 :class:`keyword` 節點的串列,主要用於 'metaclass'(元類" +"``keywords`` 是一個 :class:`.keyword` 節點的串列,主要用於 'metaclass'(元類" "別)。如 `PEP-3115 `_ 所述,其他關鍵字將被" "傳遞到 metaclass。" From 619b82a968bce2199a74e93115ef7bbd744dbf6e Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Fri, 22 Dec 2023 01:42:59 +0800 Subject: [PATCH 3/7] chore(library/ast): update based on original strings' modifications --- library/ast.po | 278 +++++++++++++++++++++++++------------------------ 1 file changed, 141 insertions(+), 137 deletions(-) diff --git a/library/ast.po b/library/ast.po index fdd106af9c..dd793e7c45 100644 --- a/library/ast.po +++ b/library/ast.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-09-09 00:03+0000\n" +"POT-Creation-Date: 2023-12-20 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:38+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -66,12 +66,12 @@ msgstr "節點 (Node) 類別" msgid "" "This is the base of all AST node classes. The actual node classes are " "derived from the :file:`Parser/Python.asdl` file, which is reproduced :ref:" -"`above `. They are defined in the :mod:`_ast` C module " +"`above `. They are defined in the :mod:`!_ast` C module " "and re-exported in :mod:`ast`." msgstr "" "這是所有 AST 節點類別的基礎。實際的節點類別是衍生自 :file:`Parser/Python." "asdl` 檔案,該檔案在\\ :ref:`上方 ` 重現。它們被定義於 :" -"mod:`_ast` 的 C 模組中,並於 :mod:`ast` 中重新匯出。" +"mod:`!_ast` 的 C 模組中,並於 :mod:`ast` 中重新匯出。" #: ../../library/ast.rst:51 msgid "" @@ -187,23 +187,23 @@ msgstr "以它們的值表示簡單索引,擴充切片 (slice) 則以元組 (t #: ../../library/ast.rst:131 msgid "" -"Old classes :class:`ast.Num`, :class:`ast.Str`, :class:`ast.Bytes`, :class:" -"`ast.NameConstant` and :class:`ast.Ellipsis` are still available, but they " -"will be removed in future Python releases. In the meantime, instantiating " -"them will return an instance of a different class." +"Old classes :class:`!ast.Num`, :class:`!ast.Str`, :class:`!ast.Bytes`, :" +"class:`!ast.NameConstant` and :class:`!ast.Ellipsis` are still available, " +"but they will be removed in future Python releases. In the meantime, " +"instantiating them will return an instance of a different class." msgstr "" -"舊的類別 :class:`ast.Num`、:class:`ast.Str`、:class:`ast.Bytes`、:class:`ast." -"NameConstant` 和 :class:`ast.Ellipsis` 仍然可用,但它們將在未來的 Python 釋出" -"版本中移除。與此同時,實例化它們將回傳不同類別的實例。" +"舊的類別 :class:`!ast.Num`、:class:`!ast.Str`、:class:`!ast.Bytes`、:class:`!" +"ast.NameConstant` 和 :class:`!ast.Ellipsis` 仍然可用,但它們將在未來的 " +"Python 釋出版本中移除。與此同時,實例化它們將回傳不同類別的實例。" #: ../../library/ast.rst:138 msgid "" -"Old classes :class:`ast.Index` and :class:`ast.ExtSlice` are still " +"Old classes :class:`!ast.Index` and :class:`!ast.ExtSlice` are still " "available, but they will be removed in future Python releases. In the " "meantime, instantiating them will return an instance of a different class." msgstr "" -"舊的類別 :class:`ast.Index` 和 :class:`ast.ExtSlice` 仍然可用,但它們將在未來" -"的 Python 版本中刪除。同時,實例化它們會回傳不同類別的實例。" +"舊的類別 :class:`!ast.Index` 和 :class:`!ast.ExtSlice` 仍然可用,但它們將在未" +"來的 Python 版本中刪除。同時,實例化它們會回傳不同類別的實例。" #: ../../library/ast.rst:144 msgid "" @@ -1086,15 +1086,14 @@ msgstr "" msgid "``returns`` is the return annotation." msgstr "``returns`` 是回傳註釋。" -#: ../../library/ast.rst:1887 ../../library/ast.rst:2065 +#: ../../library/ast.rst:1887 ../../library/ast.rst:2064 msgid "``type_params`` is a list of :ref:`type parameters `." msgstr "``type_params`` 是\\ :ref:`型別參數 `\\ 的串列。" -#: ../../library/ast.rst:1893 ../../library/ast.rst:2094 -#: ../../library/ast.rst:2105 -#, fuzzy +#: ../../library/ast.rst:1893 ../../library/ast.rst:2093 +#: ../../library/ast.rst:2104 msgid "Added ``type_params``." -msgstr "新增了“type_params”。" +msgstr "新增了 ``type_params``。" #: ../../library/ast.rst:1899 msgid "" @@ -1141,23 +1140,22 @@ msgstr "" #: ../../library/ast.rst:1937 msgid "" -"A single argument in a list. ``arg`` is a raw string of the argument name, " -"``annotation`` is its annotation, such as a :class:`Str` or :class:`Name` " -"node." +"A single argument in a list. ``arg`` is a raw string of the argument name; " +"``annotation`` is its annotation, such as a :class:`Name` node." msgstr "" "串列中的單個引數。``arg`` 是引數名稱的原始字串,``annotation`` 是它的註釋,例" -"如 :class:`Str` 或 :class:`Name` 節點。" +"如 :class:`Name` 節點。" -#: ../../library/ast.rst:1943 +#: ../../library/ast.rst:1942 msgid "" "``type_comment`` is an optional string with the type annotation as a comment" msgstr "``type_comment`` 是一個可選字串,其註解為型別註釋" -#: ../../library/ast.rst:1988 +#: ../../library/ast.rst:1987 msgid "A ``return`` statement." msgstr "一個 ``return`` 陳述式。" -#: ../../library/ast.rst:2003 +#: ../../library/ast.rst:2002 msgid "" "A ``yield`` or ``yield from`` expression. Because these are expressions, " "they must be wrapped in a :class:`Expr` node if the value sent back is not " @@ -1166,24 +1164,24 @@ msgstr "" "一個 ``yield`` 或 ``yield from`` 運算式。因為這些是運算式,所以如果不使用發送" "回來的值,則必須將它們包裝在 :class:`Expr` 節點中。" -#: ../../library/ast.rst:2028 +#: ../../library/ast.rst:2027 msgid "" "``global`` and ``nonlocal`` statements. ``names`` is a list of raw strings." msgstr "``global`` 和 ``nonlocal`` 陳述式。``names`` 是原始字串的串列。" -#: ../../library/ast.rst:2055 +#: ../../library/ast.rst:2054 msgid "A class definition." msgstr "一個類別定義。" -#: ../../library/ast.rst:2057 +#: ../../library/ast.rst:2056 msgid "``name`` is a raw string for the class name" msgstr "``name`` 是類別名的原始字串" -#: ../../library/ast.rst:2058 +#: ../../library/ast.rst:2057 msgid "``bases`` is a list of nodes for explicitly specified base classes." msgstr "``bases`` 是被顯式指定的基底類別節點串列。" -#: ../../library/ast.rst:2059 +#: ../../library/ast.rst:2058 msgid "" "``keywords`` is a list of :class:`.keyword` nodes, principally for " "'metaclass'. Other keywords will be passed to the metaclass, as per " @@ -1193,27 +1191,27 @@ msgstr "" "別)。如 `PEP-3115 `_ 所述,其他關鍵字將被" "傳遞到 metaclass。" -#: ../../library/ast.rst:2062 +#: ../../library/ast.rst:2061 msgid "" "``body`` is a list of nodes representing the code within the class " "definition." msgstr "``body`` 是表示類別定義中程式碼的節點串列。" -#: ../../library/ast.rst:2064 +#: ../../library/ast.rst:2063 msgid "``decorator_list`` is a list of nodes, as in :class:`FunctionDef`." msgstr "``decorator_list`` 是一個節點串列,如 :class:`FunctionDef` 中所示。" -#: ../../library/ast.rst:2098 +#: ../../library/ast.rst:2097 msgid "Async and await" msgstr "async 和 await" -#: ../../library/ast.rst:2102 +#: ../../library/ast.rst:2101 msgid "" "An ``async def`` function definition. Has the same fields as :class:" "`FunctionDef`." msgstr "一個 ``async def`` 函式定義。與 :class:`FunctionDef` 具有相同的欄位。" -#: ../../library/ast.rst:2111 +#: ../../library/ast.rst:2110 msgid "" "An ``await`` expression. ``value`` is what it waits for. Only valid in the " "body of an :class:`AsyncFunctionDef`." @@ -1221,7 +1219,7 @@ msgstr "" "一個 ``await`` 運算式。``value`` 是它等待的東西。僅在 :class:" "`AsyncFunctionDef` 主體 (body) 中有效。" -#: ../../library/ast.rst:2145 +#: ../../library/ast.rst:2144 msgid "" "``async for`` loops and ``async with`` context managers. They have the same " "fields as :class:`For` and :class:`With`, respectively. Only valid in the " @@ -1230,7 +1228,7 @@ msgstr "" "``async for`` 迴圈和 ``async with`` 情境管理器。它們分別具有與 :class:`For` " "和 :class:`With` 相同的欄位。僅在 :class:`AsyncFunctionDef` 主體中有效。" -#: ../../library/ast.rst:2150 +#: ../../library/ast.rst:2149 msgid "" "When a string is parsed by :func:`ast.parse`, operator nodes (subclasses of :" "class:`ast.operator`, :class:`ast.unaryop`, :class:`ast.cmpop`, :class:`ast." @@ -1243,11 +1241,11 @@ msgstr "" "boolop` 和 :class:`ast.expr_context`\\ )將是單例。對其中之一的更改將反映在所" "有其他出現的相同值中(例如 :class:`ast.Add`\\ )。" -#: ../../library/ast.rst:2158 +#: ../../library/ast.rst:2157 msgid ":mod:`ast` Helpers" msgstr ":mod:`ast` 輔助程式" -#: ../../library/ast.rst:2160 +#: ../../library/ast.rst:2159 msgid "" "Apart from the node classes, the :mod:`ast` module defines these utility " "functions and classes for traversing abstract syntax trees:" @@ -1255,7 +1253,7 @@ msgstr "" "除了節點類別之外,:mod:`ast` 模組還定義了這些用於遍歷 (traverse) 抽象語法樹的" "實用函式和類別:" -#: ../../library/ast.rst:2165 +#: ../../library/ast.rst:2164 msgid "" "Parse the source into an AST node. Equivalent to ``compile(source, " "filename, mode, ast.PyCF_ONLY_AST)``." @@ -1263,7 +1261,7 @@ msgstr "" "將原始碼剖析為 AST 節點。相當於 ``compile(source, filename, mode, ast." "PyCF_ONLY_AST)``。" -#: ../../library/ast.rst:2168 +#: ../../library/ast.rst:2167 msgid "" "If ``type_comments=True`` is given, the parser is modified to check and " "return type comments as specified by :pep:`484` and :pep:`526`. This is " @@ -1282,7 +1280,7 @@ msgstr "" "``None``。此外,``# type: ignore`` 註釋的位置將作為 :class:`Module` 的 " "``type_ignores`` 屬性回傳(否則它始終是一個空串列)。" -#: ../../library/ast.rst:2178 +#: ../../library/ast.rst:2177 msgid "" "In addition, if ``mode`` is ``'func_type'``, the input syntax is modified to " "correspond to :pep:`484` \"signature type comments\", e.g. ``(str, int) -> " @@ -1292,7 +1290,7 @@ msgstr "" "名型別註解 (signature type comments)」而被修改,例如 ``(str, int) -> " "List[str]``。" -#: ../../library/ast.rst:2182 +#: ../../library/ast.rst:2181 msgid "" "Also, setting ``feature_version`` to a tuple ``(major, minor)`` will attempt " "to parse using that Python version's grammar. Currently ``major`` must equal " @@ -1305,12 +1303,12 @@ msgstr "" "``feature_version=(3, 4)`` 將允許使用 ``async`` 和 ``await`` 作為變數名稱。有" "支援的最低版本是 ``(3, 4)``;最高的是 ``sys.version_info[0:2]``。" -#: ../../library/ast.rst:2189 +#: ../../library/ast.rst:2188 msgid "" "If source contains a null character ('\\0'), :exc:`ValueError` is raised." msgstr "如果來源包含 null 字元 ('\\0'),則會引發 :exc:`ValueError`。" -#: ../../library/ast.rst:2192 +#: ../../library/ast.rst:2191 msgid "" "Note that successfully parsing source code into an AST object doesn't " "guarantee that the source code provided is valid Python code that can be " @@ -1324,14 +1322,14 @@ msgstr "" "原始的 ``return 42`` 為 return 陳述式生成一個有效的 AST 節點,但它不能單獨編" "譯(它需要位於函式節點內)。" -#: ../../library/ast.rst:2199 +#: ../../library/ast.rst:2198 msgid "" "In particular, :func:`ast.parse` won't do any scoping checks, which the " "compilation step does." msgstr "" "特別是 :func:`ast.parse` 不會執行任何範圍檢查,而編譯步驟才會執行此操作。" -#: ../../library/ast.rst:2203 +#: ../../library/ast.rst:2202 msgid "" "It is possible to crash the Python interpreter with a sufficiently large/" "complex string due to stack depth limitations in Python's AST compiler." @@ -1339,11 +1337,11 @@ msgstr "" "由於 Python AST 編譯器中的堆疊 (stack) 深度限制,太大或太複雜的字串可能會導" "致 Python 直譯器崩潰。" -#: ../../library/ast.rst:2207 +#: ../../library/ast.rst:2206 msgid "Added ``type_comments``, ``mode='func_type'`` and ``feature_version``." msgstr "新增 ``type_comments``、``mode='func_type'`` 與 ``feature_version``。" -#: ../../library/ast.rst:2213 +#: ../../library/ast.rst:2212 msgid "" "Unparse an :class:`ast.AST` object and generate a string with code that " "would produce an equivalent :class:`ast.AST` object if parsed back with :" @@ -1352,7 +1350,7 @@ msgstr "" "反剖析 :class:`ast.AST` 物件並生成一個帶有程式碼的字串,如果使用 :func:`ast." "parse` 剖析回來,該程式碼將生成等效的 :class:`ast.AST` 物件。" -#: ../../library/ast.rst:2218 +#: ../../library/ast.rst:2217 msgid "" "The produced code string will not necessarily be equal to the original code " "that generated the :class:`ast.AST` object (without any compiler " @@ -1361,13 +1359,13 @@ msgstr "" "生成的程式碼字串不一定等於生成 :class:`ast.AST` 物件的原始程式碼(沒有任何編" "譯器最佳化,例如常數元組/凍結集合)。" -#: ../../library/ast.rst:2223 +#: ../../library/ast.rst:2222 msgid "" "Trying to unparse a highly complex expression would result with :exc:" "`RecursionError`." msgstr "嘗試剖析高度複雜的運算式會導致 :exc:`RecursionError`。" -#: ../../library/ast.rst:2231 +#: ../../library/ast.rst:2230 msgid "" "Evaluate an expression node or a string containing only a Python literal or " "container display. The string or node provided may only consist of the " @@ -1378,7 +1376,7 @@ msgstr "" "能包含以下 Python 文本結構:字串、位元組、數字、元組、串列、字典、集合、布林" "值、``None`` 和 ``Ellipsis``。" -#: ../../library/ast.rst:2236 +#: ../../library/ast.rst:2235 msgid "" "This can be used for evaluating strings containing Python values without the " "need to parse the values oneself. It is not capable of evaluating " @@ -1387,7 +1385,7 @@ msgstr "" "這可用於為包含 Python 值的字串求值,而無需自己剖析這些值。它無法計算任意複雜" "的運算式,例如涉及運算子或索引。" -#: ../../library/ast.rst:2241 +#: ../../library/ast.rst:2240 msgid "" "This function had been documented as \"safe\" in the past without defining " "what that meant. That was misleading. This is specifically designed not to " @@ -1404,13 +1402,13 @@ msgstr "" "盡或 C 堆疊耗盡,從而導致行程崩潰。某些輸入也可能會出現 CPU 消耗過多而導致拒" "絕服務的情況。因此不建議在不受信任的資料上呼叫它。" -#: ../../library/ast.rst:2251 +#: ../../library/ast.rst:2250 msgid "" "It is possible to crash the Python interpreter due to stack depth " "limitations in Python's AST compiler." msgstr "由於 Python AST 編譯器的堆疊深度限制,Python 直譯器可能會崩潰。" -#: ../../library/ast.rst:2254 +#: ../../library/ast.rst:2253 msgid "" "It can raise :exc:`ValueError`, :exc:`TypeError`, :exc:`SyntaxError`, :exc:" "`MemoryError` and :exc:`RecursionError` depending on the malformed input." @@ -1418,19 +1416,19 @@ msgstr "" "它可能會引發 :exc:`ValueError`、:exc:`TypeError`、:exc:`SyntaxError`、:exc:" "`MemoryError` 和 :exc:`RecursionError`,具體取決於格式錯誤的輸入。" -#: ../../library/ast.rst:2258 +#: ../../library/ast.rst:2257 msgid "Now allows bytes and set literals." msgstr "現在允許位元組和設定文本。" -#: ../../library/ast.rst:2261 +#: ../../library/ast.rst:2260 msgid "Now supports creating empty sets with ``'set()'``." msgstr "現在支援使用 ``'set()'`` 建立空集合。" -#: ../../library/ast.rst:2264 +#: ../../library/ast.rst:2263 msgid "For string inputs, leading spaces and tabs are now stripped." msgstr "對於字串輸入,前導空格和定位字元 (tab) 現在已被去除。" -#: ../../library/ast.rst:2270 +#: ../../library/ast.rst:2269 msgid "" "Return the docstring of the given *node* (which must be a :class:" "`FunctionDef`, :class:`AsyncFunctionDef`, :class:`ClassDef`, or :class:" @@ -1442,21 +1440,22 @@ msgstr "" "件字串則為 ``None``。如果 *clean* 為 true,則使用 :func:`inspect.cleandoc` 清" "理文件字串的縮排。" -#: ../../library/ast.rst:2276 +#: ../../library/ast.rst:2275 msgid ":class:`AsyncFunctionDef` is now supported." msgstr "目前已支援 :class:`AsyncFunctionDef`。" -#: ../../library/ast.rst:2282 +#: ../../library/ast.rst:2281 msgid "" "Get source code segment of the *source* that generated *node*. If some " -"location information (:attr:`lineno`, :attr:`end_lineno`, :attr:" -"`col_offset`, or :attr:`end_col_offset`) is missing, return ``None``." +"location information (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.end_lineno`, :" +"attr:`~ast.AST.col_offset`, or :attr:`~ast.AST.end_col_offset`) is missing, " +"return ``None``." msgstr "" -"獲取生成 *node* 的 *source* 的原始碼片段。如果某些位置資訊(:attr:`lineno`、:" -"attr:`end_lineno`、:attr:`col_offset` 或 :attr:`end_col_offset`\\ )丟失,則" -"回傳 ``None``。" +"獲取生成 *node* 的 *source* 的原始碼片段。如果某些位置資訊(:attr:`~ast.AST." +"lineno`、:attr:`~ast.AST.end_lineno`、:attr:`~ast.AST.col_offset` 或 :attr:" +"`~ast.AST.end_col_offset`\\ )丟失,則回傳 ``None``。" -#: ../../library/ast.rst:2286 +#: ../../library/ast.rst:2285 msgid "" "If *padded* is ``True``, the first line of a multi-line statement will be " "padded with spaces to match its original position." @@ -1464,20 +1463,21 @@ msgstr "" "如果 *padded* 為 ``True``,則多列陳述式的第一列將用空格填充 (padded) 以匹配其" "原始位置。" -#: ../../library/ast.rst:2294 +#: ../../library/ast.rst:2293 msgid "" "When you compile a node tree with :func:`compile`, the compiler expects :" -"attr:`lineno` and :attr:`col_offset` attributes for every node that supports " -"them. This is rather tedious to fill in for generated nodes, so this helper " -"adds these attributes recursively where not already set, by setting them to " -"the values of the parent node. It works recursively starting at *node*." +"attr:`~ast.AST.lineno` and :attr:`~ast.AST.col_offset` attributes for every " +"node that supports them. This is rather tedious to fill in for generated " +"nodes, so this helper adds these attributes recursively where not already " +"set, by setting them to the values of the parent node. It works recursively " +"starting at *node*." msgstr "" "當你使用 :func:`compile` 編譯節點樹時,編譯器預期支援它們的每個節點都有 :" -"attr:`lineno` 和 :attr:`col_offset` 屬性。填入生成的節點相當繁瑣,因此該輔助" -"工具透過將這些屬性設定為父節點的值,在尚未設定的地方遞迴地新增這些屬性。它從 " -"*node* 開始遞迴地工作。" +"attr:`~ast.AST.lineno` 和 :attr:`~ast.AST.col_offset` 屬性。填入生成的節點相" +"當繁瑣,因此該輔助工具透過將這些屬性設定為父節點的值,在尚未設定的地方遞迴地" +"新增這些屬性。它從 *node* 開始遞迴地工作。" -#: ../../library/ast.rst:2303 +#: ../../library/ast.rst:2302 msgid "" "Increment the line number and end line number of each node in the tree " "starting at *node* by *n*. This is useful to \"move code\" to a different " @@ -1486,17 +1486,17 @@ msgstr "" "將樹中從 *node* 開始的每個節點的列號和結束列號增加 *n*。這對於「移動程式碼」" "到檔案中的不同位置很有用。" -#: ../../library/ast.rst:2310 +#: ../../library/ast.rst:2309 msgid "" -"Copy source location (:attr:`lineno`, :attr:`col_offset`, :attr:" -"`end_lineno`, and :attr:`end_col_offset`) from *old_node* to *new_node* if " -"possible, and return *new_node*." +"Copy source location (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.col_offset`, :" +"attr:`~ast.AST.end_lineno`, and :attr:`~ast.AST.end_col_offset`) from " +"*old_node* to *new_node* if possible, and return *new_node*." msgstr "" -"如果可行,將原始位置(:attr:`lineno`、:attr:`col_offset`、:attr:`end_lineno` " -"和 :attr:`end_col_offset` )從 *old_node* 複製到 *new_node*,並回傳 " -"*new_node* 。" +"如果可行,將原始位置(:attr:`~ast.AST.lineno`、:attr:`~ast.AST.col_offset`、:" +"attr:`~ast.AST.end_lineno` 和 :attr:`~ast.AST.end_col_offset` )從 " +"*old_node* 複製到 *new_node*,並回傳 *new_node* 。" -#: ../../library/ast.rst:2317 +#: ../../library/ast.rst:2316 msgid "" "Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields`` " "that is present on *node*." @@ -1504,7 +1504,7 @@ msgstr "" "為 *node* 上存在的 ``node._fields`` 中的每個欄位生成一個 ``(fieldname, " "value)`` 元組。" -#: ../../library/ast.rst:2323 +#: ../../library/ast.rst:2322 msgid "" "Yield all direct child nodes of *node*, that is, all fields that are nodes " "and all items of fields that are lists of nodes." @@ -1512,7 +1512,7 @@ msgstr "" "生成 *node* 的所有直接子節點,即作為節點的所有欄位以及作為節點串列欄位的所有" "項目。" -#: ../../library/ast.rst:2329 +#: ../../library/ast.rst:2328 msgid "" "Recursively yield all descendant nodes in the tree starting at *node* " "(including *node* itself), in no specified order. This is useful if you " @@ -1521,7 +1521,7 @@ msgstr "" "遞迴地生成樹中從 *node* 開始的所有後代節點(包括 *node* 本身),不按指定順" "序。如果你只想就地修改節點而不關心情境,這非常有用。" -#: ../../library/ast.rst:2336 +#: ../../library/ast.rst:2335 msgid "" "A node visitor base class that walks the abstract syntax tree and calls a " "visitor function for every node found. This function may return a value " @@ -1530,13 +1530,13 @@ msgstr "" "節點訪問者基底類別,它遍歷抽象語法樹並為找到的每個節點呼叫訪問者函式。該函式" "可能會回傳一個由 :meth:`visit` 方法轉發的值。" -#: ../../library/ast.rst:2340 +#: ../../library/ast.rst:2339 msgid "" "This class is meant to be subclassed, with the subclass adding visitor " "methods." msgstr "這個類別應該被子類別化,子類別新增訪問者方法。" -#: ../../library/ast.rst:2345 +#: ../../library/ast.rst:2344 msgid "" "Visit a node. The default implementation calls the method called :samp:" "`self.visit_{classname}` where *classname* is the name of the node class, " @@ -1546,11 +1546,11 @@ msgstr "" "*classname* 是節點類別的名稱,或者在該方法不存在時呼叫 :meth:" "`generic_visit`。" -#: ../../library/ast.rst:2351 +#: ../../library/ast.rst:2350 msgid "This visitor calls :meth:`visit` on all children of the node." msgstr "該訪問者對該節點的所有子節點呼叫 :meth:`visit`。" -#: ../../library/ast.rst:2353 +#: ../../library/ast.rst:2352 msgid "" "Note that child nodes of nodes that have a custom visitor method won't be " "visited unless the visitor calls :meth:`generic_visit` or visits them itself." @@ -1558,7 +1558,11 @@ msgstr "" "請注意,除非訪問者呼叫 :meth:`generic_visit` 或訪問它們本身,否則不會訪問具有" "自定義訪問者方法的節點之子節點。" -#: ../../library/ast.rst:2357 +#: ../../library/ast.rst:2358 +msgid "Handles all constant nodes." +msgstr "處理所有常數節點。" + +#: ../../library/ast.rst:2360 msgid "" "Don't use the :class:`NodeVisitor` if you want to apply changes to nodes " "during traversal. For this a special visitor exists (:class:" @@ -1568,24 +1572,24 @@ msgstr "" "`NodeVisitor`。為此,有個允許修改的特殊遍歷訪問者工具 :class:" "`NodeTransformer`。" -#: ../../library/ast.rst:2363 +#: ../../library/ast.rst:2366 msgid "" -"Methods :meth:`visit_Num`, :meth:`visit_Str`, :meth:`visit_Bytes`, :meth:" -"`visit_NameConstant` and :meth:`visit_Ellipsis` are deprecated now and will " -"not be called in future Python versions. Add the :meth:`visit_Constant` " -"method to handle all constant nodes." +"Methods :meth:`!visit_Num`, :meth:`!visit_Str`, :meth:`!visit_Bytes`, :meth:" +"`!visit_NameConstant` and :meth:`!visit_Ellipsis` are deprecated now and " +"will not be called in future Python versions. Add the :meth:" +"`visit_Constant` method to handle all constant nodes." msgstr "" -":meth:`visit_Num`、:meth:`visit_Str`、:meth:`visit_Bytes`、:meth:" -"`visit_NameConstant` 和 :meth:`visit_Ellipsis` 方法現已棄用,並且不會在未來的" +":meth:`!visit_Num`、:meth:`!visit_Str`、:meth:`!visit_Bytes`、:meth:`!" +"visit_NameConstant` 和 :meth:`!visit_Ellipsis` 方法現已棄用,並且不會在未來的" "Python 版本中被呼叫。新增 :meth:`visit_Constant` 方法來處理所有常數節點。" -#: ../../library/ast.rst:2371 +#: ../../library/ast.rst:2374 msgid "" "A :class:`NodeVisitor` subclass that walks the abstract syntax tree and " "allows modification of nodes." msgstr "一個 :class:`NodeVisitor` 子類別,它會遍歷抽象語法樹並允許修改節點。" -#: ../../library/ast.rst:2374 +#: ../../library/ast.rst:2377 msgid "" "The :class:`NodeTransformer` will walk the AST and use the return value of " "the visitor methods to replace or remove the old node. If the return value " @@ -1597,7 +1601,7 @@ msgstr "" "點。如果訪問者方法的回傳值為 ``None``,則該節點將從其位置中刪除,否則將被替換" "為回傳值。回傳值可能是原始節點,在這種情況下不會發生替換。" -#: ../../library/ast.rst:2380 +#: ../../library/ast.rst:2383 msgid "" "Here is an example transformer that rewrites all occurrences of name lookups " "(``foo``) to ``data['foo']``::" @@ -1605,16 +1609,16 @@ msgstr "" "下面是一個示範用的 transformer,它將查找所有出現名稱 (``foo``) 並改寫為 " "``data['foo']``: ::" -#: ../../library/ast.rst:2392 +#: ../../library/ast.rst:2395 msgid "" "Keep in mind that if the node you're operating on has child nodes you must " -"either transform the child nodes yourself or call the :meth:`generic_visit` " -"method for the node first." +"either transform the child nodes yourself or call the :meth:`~ast." +"NodeVisitor.generic_visit` method for the node first." msgstr "" "請記住,如果你正在操作的節點有子節點,你必須自己轉換子節點或首先呼叫該節點" -"的 :meth:`generic_visit` 方法。" +"的 :meth:`~ast.NodeVisitor.generic_visit` 方法。" -#: ../../library/ast.rst:2396 +#: ../../library/ast.rst:2399 msgid "" "For nodes that were part of a collection of statements (that applies to all " "statement nodes), the visitor may also return a list of nodes rather than " @@ -1623,22 +1627,22 @@ msgstr "" "對於屬於陳述式總集 (collection) 一部分的節點(適用於所有陳述式節點),訪問者" "還可以回傳節點串列,而不僅僅是單個節點。" -#: ../../library/ast.rst:2400 +#: ../../library/ast.rst:2403 msgid "" "If :class:`NodeTransformer` introduces new nodes (that weren't part of " -"original tree) without giving them location information (such as :attr:" -"`lineno`), :func:`fix_missing_locations` should be called with the new sub-" -"tree to recalculate the location information::" +"original tree) without giving them location information (such as :attr:`~ast." +"AST.lineno`), :func:`fix_missing_locations` should be called with the new " +"sub-tree to recalculate the location information::" msgstr "" "如果 :class:`NodeTransformer` 引進了新節點(不屬於原始樹的一部分),但沒有給" -"它們提供位置資訊(例如 :attr:`lineno`\\ ),則應使用新的子節點呼叫 :func:" -"`fix_missing_locations` 樹重新計算位置資訊: ::" +"它們提供位置資訊(例如 :attr:`~ast.AST.lineno`\\ ),則應使用新的子節點呼叫 :" +"func:`fix_missing_locations` 樹重新計算位置資訊: ::" -#: ../../library/ast.rst:2408 +#: ../../library/ast.rst:2411 msgid "Usually you use the transformer like this::" msgstr "你通常會像這樣使用 transformer: ::" -#: ../../library/ast.rst:2415 +#: ../../library/ast.rst:2418 msgid "" "Return a formatted dump of the tree in *node*. This is mainly useful for " "debugging purposes. If *annotate_fields* is true (by default), the returned " @@ -1654,7 +1658,7 @@ msgstr "" "潔。預設情況下,不會轉儲列號和行偏移量等屬性。如果需要,可以設定 " "*include_attributes* 為 true。" -#: ../../library/ast.rst:2423 +#: ../../library/ast.rst:2426 msgid "" "If *indent* is a non-negative integer or string, then the tree will be " "pretty-printed with that indent level. An indent level of 0, negative, or " @@ -1668,21 +1672,21 @@ msgstr "" "(預設值)代表選擇單列表示。使用正整數縮排可以在每個級別縮排相同數量的空格。" "如果 *indent* 是一個字串(例如 ``\"\\t\"``\\ ),則該字串用於縮排每個級別。" -#: ../../library/ast.rst:2430 +#: ../../library/ast.rst:2433 msgid "Added the *indent* option." msgstr "新增 *indent* 選項。" -#: ../../library/ast.rst:2437 +#: ../../library/ast.rst:2440 msgid "Compiler Flags" msgstr "編譯器旗標" -#: ../../library/ast.rst:2439 +#: ../../library/ast.rst:2442 msgid "" "The following flags may be passed to :func:`compile` in order to change " "effects on the compilation of a program:" msgstr "可以將以下旗標傳遞給 :func:`compile` 以變更對程式的編譯效果:" -#: ../../library/ast.rst:2444 +#: ../../library/ast.rst:2447 msgid "" "Enables support for top-level ``await``, ``async for``, ``async with`` and " "async comprehensions." @@ -1690,13 +1694,13 @@ msgstr "" "啟用對最高階 ``await``、``async for``、``async with`` 和非同步綜合運算的支" "援。" -#: ../../library/ast.rst:2451 +#: ../../library/ast.rst:2454 msgid "" "Generates and returns an abstract syntax tree instead of returning a " "compiled code object." msgstr "生成並回傳抽象語法樹,而不是回傳已編譯的程式碼物件。" -#: ../../library/ast.rst:2456 +#: ../../library/ast.rst:2459 msgid "" "Enables support for :pep:`484` and :pep:`526` style type comments (``# type: " "``, ``# type: ignore ``)." @@ -1704,43 +1708,43 @@ msgstr "" "啟用對 :pep:`484` 和 :pep:`526` 樣式型別註釋的支援 (``# type: ``, ``# " "type: ignore ``)。" -#: ../../library/ast.rst:2465 +#: ../../library/ast.rst:2468 msgid "Command-Line Usage" msgstr "命令列用法" -#: ../../library/ast.rst:2469 +#: ../../library/ast.rst:2472 msgid "" "The :mod:`ast` module can be executed as a script from the command line. It " "is as simple as:" msgstr ":mod:`ast` 模組可以作為腳本從命令列執行,可以像這樣簡單地做到:" -#: ../../library/ast.rst:2476 +#: ../../library/ast.rst:2479 msgid "The following options are accepted:" msgstr "以下選項可被接受:" -#: ../../library/ast.rst:2482 +#: ../../library/ast.rst:2485 msgid "Show the help message and exit." msgstr "顯示幫助訊息並退出。" -#: ../../library/ast.rst:2487 +#: ../../library/ast.rst:2490 msgid "" "Specify what kind of code must be compiled, like the *mode* argument in :" "func:`parse`." msgstr "指定必須編譯哪種類型的程式碼,像是 :func:`parse` 中的 *mode* 引數。" -#: ../../library/ast.rst:2492 +#: ../../library/ast.rst:2495 msgid "Don't parse type comments." msgstr "不要剖析型別註解。" -#: ../../library/ast.rst:2496 +#: ../../library/ast.rst:2499 msgid "Include attributes such as line numbers and column offsets." msgstr "包括列號和行偏移量等屬性。" -#: ../../library/ast.rst:2501 +#: ../../library/ast.rst:2504 msgid "Indentation of nodes in AST (number of spaces)." msgstr "AST 中節點的縮進(空格數)。" -#: ../../library/ast.rst:2503 +#: ../../library/ast.rst:2506 msgid "" "If :file:`infile` is specified its contents are parsed to AST and dumped to " "stdout. Otherwise, the content is read from stdin." @@ -1748,7 +1752,7 @@ msgstr "" "如果指定了 :file:`infile`,則其內容將被剖析為 AST 並傾印 (dump) 到 stdout。否" "則會從 stdin 讀取內容。" -#: ../../library/ast.rst:2509 +#: ../../library/ast.rst:2512 msgid "" "`Green Tree Snakes `_, an external " "documentation resource, has good details on working with Python ASTs." @@ -1756,7 +1760,7 @@ msgstr "" "`Green Tree Snakes `_ 是一個外部文件" "資源,提供了有關使用 Python AST 的詳細資訊。" -#: ../../library/ast.rst:2512 +#: ../../library/ast.rst:2515 msgid "" "`ASTTokens `_ " "annotates Python ASTs with the positions of tokens and text in the source " @@ -1767,7 +1771,7 @@ msgstr "" "用生成它們的原始碼中的標記和文本的位置來註釋 Python AST。這對於進行原始碼轉換" "的工具很有幫助。" -#: ../../library/ast.rst:2517 +#: ../../library/ast.rst:2520 msgid "" "`leoAst.py `_ unifies the " "token-based and parse-tree-based views of python programs by inserting two-" @@ -1777,7 +1781,7 @@ msgstr "" "和 ast 節點之間插入雙向鏈結,統一了 python 程式的基於 token 和基於剖析樹的視" "圖。" -#: ../../library/ast.rst:2521 +#: ../../library/ast.rst:2524 msgid "" "`LibCST `_ parses code as a Concrete Syntax " "Tree that looks like an ast tree and keeps all formatting details. It's " @@ -1787,7 +1791,7 @@ msgstr "" "(Concrete Syntax Tree),看起來像 ast 樹並保留所有格式詳細資訊。它對於建置自動" "重構 (codemod) 應用程式和 linter 非常有用。" -#: ../../library/ast.rst:2526 +#: ../../library/ast.rst:2529 msgid "" "`Parso `_ is a Python parser that supports " "error recovery and round-trip parsing for different Python versions (in " From 5f6f5ac6702795888070cd00a881e2f7d5ca7e66 Mon Sep 17 00:00:00 2001 From: "Wei-Hsiang (Matt) Wang" Date: Mon, 25 Dec 2023 10:55:00 +0800 Subject: [PATCH 4/7] Apply suggestions from code review Co-authored-by: Payon --- library/ast.po | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/ast.po b/library/ast.po index dd793e7c45..7f9bef574c 100644 --- a/library/ast.po +++ b/library/ast.po @@ -1418,7 +1418,7 @@ msgstr "" #: ../../library/ast.rst:2257 msgid "Now allows bytes and set literals." -msgstr "現在允許位元組和設定文本。" +msgstr "現在允許位元組和集合文本 (set literal)。" #: ../../library/ast.rst:2260 msgid "Now supports creating empty sets with ``'set()'``." @@ -1453,7 +1453,7 @@ msgid "" msgstr "" "獲取生成 *node* 的 *source* 的原始碼片段。如果某些位置資訊(:attr:`~ast.AST." "lineno`、:attr:`~ast.AST.end_lineno`、:attr:`~ast.AST.col_offset` 或 :attr:" -"`~ast.AST.end_col_offset`\\ )丟失,則回傳 ``None``。" +"`~ast.AST.end_col_offset`\\ )遺漏,則回傳 ``None``。" #: ../../library/ast.rst:2285 msgid "" @@ -1472,7 +1472,7 @@ msgid "" "set, by setting them to the values of the parent node. It works recursively " "starting at *node*." msgstr "" -"當你使用 :func:`compile` 編譯節點樹時,編譯器預期支援它們的每個節點都有 :" +"當你使用 :func:`compile` 編譯節點樹時,編譯器預期每個節點都有支援 :" "attr:`~ast.AST.lineno` 和 :attr:`~ast.AST.col_offset` 屬性。填入生成的節點相" "當繁瑣,因此該輔助工具透過將這些屬性設定為父節點的值,在尚未設定的地方遞迴地" "新增這些屬性。它從 *node* 開始遞迴地工作。" @@ -1615,7 +1615,7 @@ msgid "" "either transform the child nodes yourself or call the :meth:`~ast." "NodeVisitor.generic_visit` method for the node first." msgstr "" -"請記住,如果你正在操作的節點有子節點,你必須自己轉換子節點或首先呼叫該節點" +"請記住,如果你正在操作的節點有子節點,你必須自己轉換子節點或先呼叫該節點" "的 :meth:`~ast.NodeVisitor.generic_visit` 方法。" #: ../../library/ast.rst:2399 @@ -1635,8 +1635,8 @@ msgid "" "sub-tree to recalculate the location information::" msgstr "" "如果 :class:`NodeTransformer` 引進了新節點(不屬於原始樹的一部分),但沒有給" -"它們提供位置資訊(例如 :attr:`~ast.AST.lineno`\\ ),則應使用新的子節點呼叫 :" -"func:`fix_missing_locations` 樹重新計算位置資訊: ::" +"它們提供位置資訊(例如 :attr:`~ast.AST.lineno`\\ ),則應使用新的子樹呼叫 :" +"func:`fix_missing_locations` 以重新計算位置資訊: ::" #: ../../library/ast.rst:2411 msgid "Usually you use the transformer like this::" From 248d88ef478b599ce82ef360caa8df2f30920b16 Mon Sep 17 00:00:00 2001 From: "Wei-Hsiang (Matt) Wang" Date: Mon, 25 Dec 2023 11:30:05 +0800 Subject: [PATCH 5/7] Apply suggestions from code review --- library/ast.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/ast.po b/library/ast.po index 7f9bef574c..857d1311a2 100644 --- a/library/ast.po +++ b/library/ast.po @@ -1652,10 +1652,10 @@ msgid "" "dumped by default. If this is wanted, *include_attributes* can be set to " "true." msgstr "" -"回傳 *node* 中樹的格式化轉儲 (formatted dump),這主要用於除錯。如果 " +"回傳 *node* 中樹的格式化傾印 (formatted dump),這主要用於除錯。如果 " "*annotate_fields* 為 true(為預設值),則回傳的字串將顯示欄位的名稱和值。如" "果 *annotate_fields* 為 false,則透過省略明確的欄位名稱,結果字串將更加縮減簡" -"潔。預設情況下,不會轉儲列號和行偏移量等屬性。如果需要,可以設定 " +"潔。預設情況下,不會傾印列號和行偏移量等屬性。如果需要,可以設定 " "*include_attributes* 為 true。" #: ../../library/ast.rst:2426 From 791536ee8ae0b1611503255ce2d7cf72bcfb4855 Mon Sep 17 00:00:00 2001 From: "Wei-Hsiang (Matt) Wang" Date: Mon, 25 Dec 2023 11:33:00 +0800 Subject: [PATCH 6/7] Apply suggestions from code review --- library/ast.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ast.po b/library/ast.po index 857d1311a2..2b462d6cdd 100644 --- a/library/ast.po +++ b/library/ast.po @@ -1475,7 +1475,7 @@ msgstr "" "當你使用 :func:`compile` 編譯節點樹時,編譯器預期每個節點都有支援 :" "attr:`~ast.AST.lineno` 和 :attr:`~ast.AST.col_offset` 屬性。填入生成的節點相" "當繁瑣,因此該輔助工具透過將這些屬性設定為父節點的值,在尚未設定的地方遞迴地" -"新增這些屬性。它從 *node* 開始遞迴地工作。" +"新增這些屬性。它從 *node* 開始遞迴地作用。" #: ../../library/ast.rst:2302 msgid "" From 427debc435f3c8bd7d4fd7fc8ebcc2f5529f25a5 Mon Sep 17 00:00:00 2001 From: "Wei-Hsiang (Matt) Wang" Date: Mon, 25 Dec 2023 08:03:21 +0000 Subject: [PATCH 7/7] fix(library/ast): modify based on review comment --- library/ast.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/ast.po b/library/ast.po index 2b462d6cdd..c3e60d8ea3 100644 --- a/library/ast.po +++ b/library/ast.po @@ -1472,10 +1472,10 @@ msgid "" "set, by setting them to the values of the parent node. It works recursively " "starting at *node*." msgstr "" -"當你使用 :func:`compile` 編譯節點樹時,編譯器預期每個節點都有支援 :" -"attr:`~ast.AST.lineno` 和 :attr:`~ast.AST.col_offset` 屬性。填入生成的節點相" -"當繁瑣,因此該輔助工具透過將這些屬性設定為父節點的值,在尚未設定的地方遞迴地" -"新增這些屬性。它從 *node* 開始遞迴地作用。" +"當你使用 :func:`compile` 編譯節點樹時,對於每個有支援 :attr:`~ast.AST." +"lineno` 和 :attr:`~ast.AST.col_offset` 屬性之節點,編譯器預期他們的這些屬性都" +"要存在。填入生成的節點相當繁瑣,因此該輔助工具透過將這些屬性設定為父節點的" +"值,在尚未設定的地方遞迴地新增這些屬性。它從 *node* 開始遞迴地作用。" #: ../../library/ast.rst:2302 msgid ""