From e7d2c37cd38069419a1fac15e0ed2ba163afc82b Mon Sep 17 00:00:00 2001 From: Steven Hsu <81967953+StevenHsuYL@users.noreply.github.com> Date: Sat, 22 May 2021 11:09:10 +0800 Subject: [PATCH 1/4] tutorial/comtrolflow.po Completed. --- tutorial/controlflow.po | 643 ++++++++++++++++++++++++++-------------- 1 file changed, 413 insertions(+), 230 deletions(-) diff --git a/tutorial/controlflow.po b/tutorial/controlflow.po index bb1521c49d..b6c5bc9eab 100644 --- a/tutorial/controlflow.po +++ b/tutorial/controlflow.po @@ -6,12 +6,13 @@ # Liang-Bo Wang , 2015 # Liang-Bo Wang , 2016 # hsiao yi , 2015 +# Steven Hsu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.7\n" +"Project-Id-Version: Python 3.9\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-20 18:08+0800\n" -"PO-Revision-Date: 2018-09-07 17:30+0800\n" +"POT-Creation-Date: 2021-05-18 12:27+0800\n" +"PO-Revision-Date: 2021-05-21 09:40+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -20,25 +21,23 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 2.1.1\n" +"X-Generator: Poedit 2.4.3\n" #: ../../tutorial/controlflow.rst:5 msgid "More Control Flow Tools" msgstr "深入了解流程控制" #: ../../tutorial/controlflow.rst:7 -#, fuzzy msgid "" "Besides the :keyword:`while` statement just introduced, Python uses the " "usual flow control statements known from other languages, with some twists." msgstr "" "除了剛才介紹的 :keyword:`while`,Python 擁有在其他程式語言中常用的流程控制語" -"法,並有ㄧ些不一樣的改變。" +"法,並有一些不一樣的改變。" #: ../../tutorial/controlflow.rst:14 -#, fuzzy msgid ":keyword:`!if` Statements" -msgstr ":keyword:`if` 陳述式" +msgstr ":keyword:`!if` 陳述式" #: ../../tutorial/controlflow.rst:16 msgid "" @@ -50,7 +49,6 @@ msgstr "" "::" #: ../../tutorial/controlflow.rst:33 -#, fuzzy msgid "" "There can be zero or more :keyword:`elif` parts, and the :keyword:`else` " "part is optional. The keyword ':keyword:`!elif`' is short for 'else if', " @@ -58,18 +56,16 @@ msgid "" "keyword:`!elif` ... :keyword:`!elif` ... sequence is a substitute for the " "``switch`` or ``case`` statements found in other languages." msgstr "" -"可以有零個或多個 :keyword:`elif` 段落,且 :keyword:`else` 段落可有可無。關鍵" -"字 :keyword:`elif` 只是「else if」的縮寫,並且用來避免過多的縮排。一個 :" -"keyword:`if` ... :keyword:`elif` ... :keyword:`elif` ... 序列可以用來替代其他" -"語言中出現的 ``switch`` 或 ``case`` 陳述式。" +"在陳述式中,可以沒有或有許多個 :keyword:`elif` 敘述,且 :keyword:`else` 敘述" +"並不是必要的。關鍵字 :keyword:`!elif` 是「else if」的縮寫,用來避免過多的縮" +"排。一個 :keyword:`!if` ... :keyword:`!elif` ... :keyword:`!elif` ... 序列可" +"以用來替代其他程式語言中的 ``switch`` 或 ``case`` 陳述式。" #: ../../tutorial/controlflow.rst:43 -#, fuzzy msgid ":keyword:`!for` Statements" -msgstr ":keyword:`for` 陳述式" +msgstr ":keyword:`!for` 陳述式" #: ../../tutorial/controlflow.rst:48 -#, fuzzy msgid "" "The :keyword:`for` statement in Python differs a bit from what you may be " "used to in C or Pascal. Rather than always iterating over an arithmetic " @@ -79,10 +75,10 @@ msgid "" "a string), in the order that they appear in the sequence. For example (no " "pun intended):" msgstr "" -"在 Python 中的 :keyword:`for` 陳述式可能不同於在 C 或 Pascal 中所看到的使用方" -"式。與其只能疊代 (iterate) 一個等差級數(如 Pascal),或給與使用者定義疊代步" -"進方式與結束條件(如 C),Python 的 :keyword:`for` 陳述疊代任何序列(list 或" -"者字串)的元素,以他們出現在序列中的順序。例如(無意雙關):\n" +"在 Python 中的 :keyword:`for` 陳述式有點不同於在 C 或 Pascal 中的慣用方式。相" +"較於只能疊代 (iterate) 一個等差數列(如 Pascal),或給予使用者定義疊代步驟與" +"暫停條件(如 C),Python 的 :keyword:`!for` 陳述式疊代任何序列(list 或者字" +"串)的項目,項目的順序與他們出現在序列中的順序相同。例如(無意雙關):\n" "\n" "::" @@ -92,6 +88,10 @@ msgid "" "can be tricky to get right. Instead, it is usually more straight-forward to " "loop over a copy of the collection or to create a new collection::" msgstr "" +"在疊代一個集合的同時修改該集合的內容,很難獲取想要的結果。比較直觀的替代方" +"式,是疊代該集合的副本,或創建一個新的集合:\n" +"\n" +"::" #: ../../tutorial/controlflow.rst:88 msgid "The :func:`range` Function" @@ -103,7 +103,7 @@ msgid "" "func:`range` comes in handy. It generates arithmetic progressions::" msgstr "" "如果你需要疊代一個數列的話,使用內建 :func:`range` 函式就很方便。它可以生成一" -"等差級數:\n" +"等差數列:\n" "\n" "::" @@ -115,8 +115,8 @@ msgid "" "a different increment (even negative; sometimes this is called the 'step')::" msgstr "" "給定的結束值永遠不會出現在生成的序列中;\\ ``range(10)`` 生成的 10 個數值,即" -"對應存取一個長度為 10 的序列內每一個元素的索引值。也可以讓 range 從其他數值計" -"數,或者給定不同的級距(甚至為負;有時稱之為 step):\n" +"對應存取一個長度為 10 的序列內每一個項目的索引值。也可以讓 range 從其他數值開" +"始計數,或者給定不同的公差(甚至為負;有時稱之為 step):\n" "\n" "::" @@ -151,12 +151,11 @@ msgid "" "items of the desired sequence when you iterate over it, but it doesn't " "really make the list, thus saving space." msgstr "" -"在很多情況下,由 :func:`range` 回傳的物件的行為如同一個 list,但實際上它並不" -"是。它是一個物件在你疊代時會回傳想要的序列的連續元素,並不會真正建出這個序列" -"的 list,以節省空間。" +"在很多情況下,由 :func:`range` 回傳的物件表現得像是一個 list(串列)一樣,但" +"實際上它並不是。它是一個在疊代時能夠回傳所要求的序列中所有項目的物件,但它不" +"會真正建出這個序列的 list,以節省空間。" #: ../../tutorial/controlflow.rst:142 -#, fuzzy msgid "" "We say such an object is :term:`iterable`, that is, suitable as a target for " "functions and constructs that expect something from which they can obtain " @@ -164,45 +163,47 @@ msgid "" "keyword:`for` statement is such a construct, while an example of a function " "that takes an iterable is :func:`sum`::" msgstr "" -"我們稱這樣的物件為 *iterable*\\ (可疊代的),意即能作為函式、陳述式中能一直" -"獲取連續元素直到用盡的部件。我們已經看過 :keyword:`for` 陳述式可做為如此的 " -"*iterator*\\ (疊代器)。:func:`list` 函式為另一個例子,他可以自 iterable(可" -"疊代物件)建立 list:\n" +"我們稱這樣的物件為 :term:`iterable`\\ (可疊代物件),意即能作為函式及架構中" +"可以一直獲取項目直到取盡的對象。我們已經了解 :keyword:`for` 陳述式就是如此的" +"架構,另一個使用 iterable 的函式範例是 :func:`sum`\\ :\n" "\n" "::" #: ../../tutorial/controlflow.rst:151 -#, fuzzy msgid "" "Later we will see more functions that return iterables and take iterables as " "arguments. Lastly, maybe you are curious about how to get a list from a " "range. Here is the solution::" -msgstr "待會我們可以看到更多函式回傳 iterable 和接受 iterable 為引數。" +msgstr "" +"待會我們可以看到更多回傳 iterable 和使用 iterable 為引數的函式。最後,也許你" +"會好奇如何從 range 中得到一個 list。解法如下:\n" +"\n" +"::" #: ../../tutorial/controlflow.rst:158 msgid "" "In chapter :ref:`tut-structures`, we will discuss in more detail about :func:" "`list`." msgstr "" +"在\\ :ref:`tut-structures`\\ 章節中,我們會討論更多關於 :func:`list` 的細節。" #: ../../tutorial/controlflow.rst:164 -#, fuzzy msgid "" ":keyword:`!break` and :keyword:`!continue` Statements, and :keyword:`!else` " "Clauses on Loops" msgstr "" -":keyword:`break` 和 :keyword:`continue` 陳述、迴圈內 :keyword:`else` 段落" +"迴圈內的 :keyword:`!break` 和 :keyword:`!continue` 陳述式及 :keyword:`!else` " +"子句" #: ../../tutorial/controlflow.rst:166 msgid "" "The :keyword:`break` statement, like in C, breaks out of the innermost " "enclosing :keyword:`for` or :keyword:`while` loop." msgstr "" -":keyword:`break` 陳述,如同 C 語言,終止包含其最內部的 :keyword:`for` 或 :" +":keyword:`break` 陳述式,如同 C 語言,終止包含它的最內部 :keyword:`for` 或 :" "keyword:`while` 迴圈。" #: ../../tutorial/controlflow.rst:169 -#, fuzzy msgid "" "Loop statements may have an :keyword:`!else` clause; it is executed when the " "loop terminates through exhaustion of the iterable (with :keyword:`for`) or " @@ -210,9 +211,10 @@ msgid "" "loop is terminated by a :keyword:`break` statement. This is exemplified by " "the following loop, which searches for prime numbers::" msgstr "" -"迴圈可以帶有一個 ``else`` 段落。當迴圈歷遍疊代的 list (在 :keyword:`for` " -"中)或條件為偽(在 :keyword:`while` 中)時,這個段落會被執行;但迴圈被 :" -"keyword:`break` 陳述終止時則不會。底下尋找質數的迴圈即示範了這個行為:\n" +"迴圈陳述式可以帶有一個 :keyword:`!else` 子句。當迴圈用盡所有的 iterable " +"(在 :keyword:`for` 中)或條件為假(在 :keyword:`while` 中)時,這個子句會被" +"執行;但迴圈被 :keyword:`break` 陳述式終止時則不會執行。底下尋找質數的迴圈即" +"示範了這個行為:\n" "\n" "::" @@ -221,11 +223,10 @@ msgid "" "(Yes, this is the correct code. Look closely: the ``else`` clause belongs " "to the :keyword:`for` loop, **not** the :keyword:`if` statement.)" msgstr "" -"(沒錯,這是正確的程式碼。請看仔細:``else`` 段落屬於 :keyword:`for` 迴" -"圈,\\ **並非** :keyword:`if` 陳述。)" +"(沒錯,這是正確的程式碼。請看仔細:``else`` 子句屬於 :keyword:`for` 迴圈,**" +"並非** :keyword:`if` 陳述式。)" #: ../../tutorial/controlflow.rst:196 -#, fuzzy msgid "" "When used with a loop, the ``else`` clause has more in common with the " "``else`` clause of a :keyword:`try` statement than it does with that of :" @@ -234,60 +235,59 @@ msgid "" "``break`` occurs. For more on the :keyword:`!try` statement and exceptions, " "see :ref:`tut-handling`." msgstr "" -"當 ``else`` 段落與迴圈使用時,相較於搭配 :keyword:`if` 陳述使用,它的行為與搭" -"配 :keyword:`try` 陳述使用時更為相似:\\ :keyword:`try` 的 ``else`` 段落在沒" -"有任何例外 (exception) 時執行,而迴圈的 ``else`` 段落在沒有任何 ``break`` 時" -"執行。更多有關 :keyword:`try` 陳述和例外的介紹,見\\ :ref:`tut-handling`\\ 。" +"當 ``else`` 子句用於迴圈時,相較於搭配 :keyword:`if` 陳述式使用,它的行為與 :" +"keyword:`try` 陳述式中的 ``else`` 子句更為相似::keyword:`try` 陳述式的 " +"``else`` 子句在沒有發生例外 (exception) 時執行,而迴圈的 ``else`` 子句在沒有" +"任何 ``break`` 發生時執行。更多有關 :keyword:`!try` 陳述式和例外的介紹,見" +"\\ :ref:`tut-handling`\\ 。" #: ../../tutorial/controlflow.rst:203 msgid "" "The :keyword:`continue` statement, also borrowed from C, continues with the " "next iteration of the loop::" msgstr "" -":keyword:`continue` 陳述,亦承襲於 C 語言,讓所屬的迴圈繼續執行下個疊代:\n" +":keyword:`continue` 陳述式,亦承襲於 C 語言,讓所屬的迴圈繼續執行下個疊代:\n" "\n" "::" -#: ../../tutorial/controlflow.rst:223 -#, fuzzy +#: ../../tutorial/controlflow.rst:224 msgid ":keyword:`!pass` Statements" -msgstr ":keyword:`pass` 陳述式" +msgstr ":keyword:`!pass` 陳述式" -#: ../../tutorial/controlflow.rst:225 +#: ../../tutorial/controlflow.rst:226 msgid "" "The :keyword:`pass` statement does nothing. It can be used when a statement " "is required syntactically but the program requires no action. For example::" msgstr "" -":keyword:`pass` 陳述不執行任何動作。它用在語法上需要一個陳述但不需要執行任何" -"動作的時候。例如:\n" +":keyword:`pass` 陳述式不執行任何動作。它可用在語法上需要一個陳述式但程式不需" +"要執行任何動作的時候。例如:\n" "\n" "::" -#: ../../tutorial/controlflow.rst:232 +#: ../../tutorial/controlflow.rst:233 msgid "This is commonly used for creating minimal classes::" msgstr "" -"這經常用於定義一個最簡單的類別:\n" +"這經常用於建立簡單的 class(類別):\n" "\n" "::" -#: ../../tutorial/controlflow.rst:238 -#, fuzzy +#: ../../tutorial/controlflow.rst:239 msgid "" "Another place :keyword:`pass` can be used is as a place-holder for a " "function or conditional body when you are working on new code, allowing you " "to keep thinking at a more abstract level. The :keyword:`!pass` is silently " "ignored::" msgstr "" -":keyword:`pass` 亦可作為一個函式或條件判斷主體的預留位置,它可幫助你以更宏觀" -"的角度思考並撰寫新的程式碼。\\ :keyword:`pass` 可被忽略:\n" +":keyword:`pass` 亦可作為一個函式或條件判斷主體的預留位置,在你撰寫新的程式碼" +"時讓你保持在更抽象的思維層次。:keyword:`!pass` 可以直接被略過:\n" "\n" "::" -#: ../../tutorial/controlflow.rst:249 +#: ../../tutorial/controlflow.rst:250 msgid "Defining Functions" msgstr "定義函式 (function)" -#: ../../tutorial/controlflow.rst:251 +#: ../../tutorial/controlflow.rst:252 msgid "" "We can create a function that writes the Fibonacci series to an arbitrary " "boundary::" @@ -296,17 +296,18 @@ msgstr "" "\n" "::" -#: ../../tutorial/controlflow.rst:271 +#: ../../tutorial/controlflow.rst:272 msgid "" "The keyword :keyword:`def` introduces a function *definition*. It must be " "followed by the function name and the parenthesized list of formal " "parameters. The statements that form the body of the function start at the " "next line, and must be indented." msgstr "" -"關鍵字 :keyword:`def` 帶入一個函式的\\ *定義*。它之後必須連著該函式的名稱和置" -"於括號之中的參數。自下一行起,所有縮排的陳述成為該函式的主體。" +"關鍵字 :keyword:`def` 介紹一個函式的\\ *定義*\\ 。它之後必須連著該函式的名稱" +"和置於括號之中的形式參數 (parameter) 串列。自下一行起,所有縮排的陳述式成為該" +"函式的主體。" -#: ../../tutorial/controlflow.rst:276 +#: ../../tutorial/controlflow.rst:277 msgid "" "The first statement of the function body can optionally be a string literal; " "this string literal is the function's documentation string, or :dfn:" @@ -316,14 +317,13 @@ msgid "" "through code; it's good practice to include docstrings in code that you " "write, so make a habit of it." msgstr "" -"一個函式的第一個陳述可以是一個字串值;此情況該字串值被視為該函式的說明文件字" +"一個函式的第一個陳述式可以是一個字串文字;該字串文字被視為該函式的說明文件字" "串,即 :dfn:`docstring`\\ 。(關於 docstring 的細節請參見\\ :ref:`tut-" "docstrings`\\ 段落。)有些工具可以使用 docstring 來自動產生線上或可列印的文" -"件,或讓使用者能自由地自原始碼中瀏覽文件。在原始碼中加入 docstring 是個好慣" -"例,應該養成這樣的習慣。" +"件,或讓使用者能以互動方式瀏覽原始碼。在原始碼中加入 docstring 是個好慣例,應" +"該養成這樣的習慣。" -#: ../../tutorial/controlflow.rst:283 -#, fuzzy +#: ../../tutorial/controlflow.rst:284 msgid "" "The *execution* of a function introduces a new symbol table used for the " "local variables of the function. More precisely, all variable assignments " @@ -336,40 +336,43 @@ msgid "" "for variables of enclosing functions, named in a :keyword:`nonlocal` " "statement), although they may be referenced." msgstr "" -"函式執行期間會建立一個新的符號表(symbol table)來儲存該函式內的區域變數。更" -"精確地說,所有在函式內的變數賦值都會把該值儲存在一個區域符號表。然而,在讀取" -"一個變數時,會先從區域符號表起搜尋,其次為所有包含其函式的區域符號表,其次為" -"全域符號表,最後為所有內建的名稱。因此,在函式中,全域變數無法被直接賦值(除" -"非該變數有被 :keyword:`global` 陳述句提及),但它們可以被讀取。" +"函式\\ *執行*\\ 時會建立一個新的符號表 (symbol table) 來儲存該函式內的區域變" +"數 (local variable)。更精確地說,所有在函式內的變數賦值都會把該值儲存在一個區" +"域符號表。然而,在引用一個變數時,會先從區域符號表開始搜尋,其次為外層函式的" +"區域符號表,其次為全域符號表 (global symbol table),最後為所有內建的名稱。因" +"此,在函式中,全域變數及外層函式變數雖然可以被引用,但無法被直接賦值(除非全" +"域變數是在 :keyword:`global` 陳述式中被定義,或外層函式變數在 :keyword:" +"`nonlocal` 陳述式中被定義)。" -#: ../../tutorial/controlflow.rst:294 +#: ../../tutorial/controlflow.rst:295 msgid "" "The actual parameters (arguments) to a function call are introduced in the " "local symbol table of the called function when it is called; thus, arguments " "are passed using *call by value* (where the *value* is always an object " "*reference*, not the value of the object). [#]_ When a function calls " -"another function, a new local symbol table is created for that call." +"another function, or calls itself recursively, a new local symbol table is " +"created for that call." msgstr "" -"在一個函式被呼叫的時候,實際傳入的參數(引數)會被加入至該函數的區域符號表。" -"因此,引數傳入的方式為\\ *傳值呼叫 (call by value)*\\ (這裡傳遞的「值」永遠" -"是一個物件的\\ *參照(reference)*\\ ,而不是該物件的值)。\\ [#]_ 當一個函式" -"呼叫別的函式時,在被呼叫的函式中會建立一個新的區域符號表。" +"在一個函式被呼叫的時候,實際傳入的參數(引數)會被加入至該函式的區域符號表。" +"因此,引數傳入的方式為\\ *傳值呼叫 (call by value)*\\ (這裡傳遞的\\ *值*\\ " +"永遠是一個物件的\\ *參照 (reference)*\\ ,而不是該物件的值)。\\ [#]_ 當一個" +"函式呼叫別的函式或遞迴呼叫它自己時,在被呼叫的函式中會建立一個新的區域符號" +"表。" -#: ../../tutorial/controlflow.rst:300 +#: ../../tutorial/controlflow.rst:302 msgid "" -"A function definition introduces the function name in the current symbol " -"table. The value of the function name has a type that is recognized by the " -"interpreter as a user-defined function. This value can be assigned to " -"another name which can then also be used as a function. This serves as a " -"general renaming mechanism::" +"A function definition associates the function name with the function object " +"in the current symbol table. The interpreter recognizes the object pointed " +"to by that name as a user-defined function. Other names can also point to " +"that same function object and can also be used to access the function::" msgstr "" -"一個函式定義會把該函式名稱加入至當前的符號表。該函式名稱的值帶有一個型別,並" -"被直譯器辨識為使用者自定函式(user-defined function)。該值可以被賦予給別的變" -"數名,而該變數也可以被當作函式使用。這即是常見的重新命名方式:\n" +"函式定義時,會把該函式名稱加入至當前的符號表。函式名稱的值帶有一個型別,並被" +"直譯器辨識為使用者自定函式 (user-defined function)。該值可以被指定給別的變數" +"名,使該變數名也可以被當作函式使用。這是常見的重新命名方式:\n" "\n" "::" -#: ../../tutorial/controlflow.rst:312 +#: ../../tutorial/controlflow.rst:313 msgid "" "Coming from other languages, you might object that ``fib`` is not a function " "but a procedure since it doesn't return a value. In fact, even functions " @@ -380,13 +383,14 @@ msgid "" "`print`::" msgstr "" "如果你是來自別的語言,你可能不同意 ``fib`` 是個函式,而是個程序 (procedure)," -"因為它並沒有回傳值。實際上,即使一個函式缺少一個 :keyword:`return` 陳述,它亦" -"有一個固定的回傳值。這個值為 ``None``\\ (它是一個內建名稱)。在直譯器中單獨" -"使用 ``None`` 時,通常不會被顯示。你可以使用 :func:`print` 來看到它:\n" +"因為它並沒有回傳值。實際上,即使一個函式缺少一個 :keyword:`return` 陳述式,它" +"亦有一個固定的回傳值。這個值稱為 ``None``\\ (它是一個內建名稱)。如果 " +"``None`` 是唯一的回傳值,一般不會被直譯器顯示。你可以使用 :func:`print` 來看" +"到它:\n" "\n" "::" -#: ../../tutorial/controlflow.rst:323 +#: ../../tutorial/controlflow.rst:324 msgid "" "It is simple to write a function that returns a list of the numbers of the " "Fibonacci series, instead of printing it::" @@ -395,22 +399,21 @@ msgstr "" "\n" "::" -#: ../../tutorial/controlflow.rst:339 +#: ../../tutorial/controlflow.rst:340 msgid "This example, as usual, demonstrates some new Python features:" msgstr "這個例子一樣示範了一些新的 Python 特性:" -#: ../../tutorial/controlflow.rst:341 -#, fuzzy +#: ../../tutorial/controlflow.rst:342 msgid "" "The :keyword:`return` statement returns with a value from a function. :" "keyword:`!return` without an expression argument returns ``None``. Falling " "off the end of a function also returns ``None``." msgstr "" -":keyword:`return` 陳述會讓一個函式回傳一個值。單獨使用 :keyword:`return` 不外" -"加一個表達式作為引數會回傳 ``None``\\ 。一個函式執行到結束也會回傳 ``None``" -"\\ 。" +":keyword:`return` 陳述式會讓一個函式回傳一個值。單獨使用 :keyword:`!return` " +"不外加一個運算式作為引數時會回傳 ``None``\\ 。一個函式執行到結束也會回傳 " +"``None``\\ 。" -#: ../../tutorial/controlflow.rst:345 +#: ../../tutorial/controlflow.rst:346 msgid "" "The statement ``result.append(a)`` calls a *method* of the list object " "``result``. A method is a function that 'belongs' to an object and is named " @@ -423,114 +426,144 @@ msgid "" "for list objects; it adds a new element at the end of the list. In this " "example it is equivalent to ``result = result + [a]``, but more efficient." msgstr "" -"``result.append(a)`` 陳述呼叫了一個 list 物件的 ``result`` *method(方法)*。" -"method 為「屬於」一個物件的函式,命名規則為 ``obj.methodname``\\ ,其中 " -"``obj`` 為某個物件(亦可為一表達式),而 ``methodname`` 為該 method 的名稱," -"並由該物件的型別所定義。不同的型別代表不同的 method。不同型別的 method 可以擁" -"有一樣的名稱而不會讓 Python 混淆。(你可以使用 *class* 定義自己的物件型別和 " -"method,見 :ref:`tut-classes`\\ )這裡 :meth:`append` method 定義在 list 物件" -"中;它會加入一個新的元素在該 list 的末端。這個例子等同於 ``result = result + " -"[a]``\\ ,但更有效率。" +"``result.append(a)`` 陳述式呼叫了一個 list 物件 ``result`` 的 *method(方法)" +"*\\ 。method 為「屬於」一個物件的函式,命名規則為 ``obj.methodname``\\ ,其" +"中 ``obj`` 為某個物件(亦可為一運算式),而 ``methodname`` 為該 method 的名" +"稱,並由該物件的型別所定義。不同的型別定義不同的 method。不同型別的 method 可" +"以擁有一樣的名稱而不會讓 Python 混淆。(你可以使用 *class*\\ (類別)定義自己" +"的物件型別和 method,見 :ref:`tut-classes`\\ )範例中的 :meth:`append` " +"method 定義在 list 物件中;它會在該 list 的末端加入一個新的元素。這個例子等同" +"於 ``result = result + [a]``\\ ,但更有效率。" -#: ../../tutorial/controlflow.rst:360 +#: ../../tutorial/controlflow.rst:361 msgid "More on Defining Functions" -msgstr "" +msgstr "深入了解函式定義" -#: ../../tutorial/controlflow.rst:362 +#: ../../tutorial/controlflow.rst:363 msgid "" "It is also possible to define functions with a variable number of arguments. " "There are three forms, which can be combined." msgstr "" +"定義函式時使用的引數 (argument) 數量是可變的。總共有三種可以組合使用的形式。" -#: ../../tutorial/controlflow.rst:369 +#: ../../tutorial/controlflow.rst:370 msgid "Default Argument Values" -msgstr "" +msgstr "預設引數值" -#: ../../tutorial/controlflow.rst:371 +#: ../../tutorial/controlflow.rst:372 msgid "" "The most useful form is to specify a default value for one or more " "arguments. This creates a function that can be called with fewer arguments " "than it is defined to allow. For example::" msgstr "" +"為一個或多個引數指定預設值是很有用的方式。函式建立後,可以用比定義時更少的引" +"數呼叫該函式。例如:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:387 +#: ../../tutorial/controlflow.rst:388 msgid "This function can be called in several ways:" -msgstr "" +msgstr "該函式可以用以下幾種方式被呼叫:" -#: ../../tutorial/controlflow.rst:389 +#: ../../tutorial/controlflow.rst:390 msgid "" "giving only the mandatory argument: ``ask_ok('Do you really want to quit?')``" -msgstr "" +msgstr "只給必選引數:\\ ``ask_ok('Do you really want to quit?')``" -#: ../../tutorial/controlflow.rst:391 +#: ../../tutorial/controlflow.rst:392 msgid "" "giving one of the optional arguments: ``ask_ok('OK to overwrite the file?', " "2)``" -msgstr "" +msgstr "給予一個可選引數:\\ ``ask_ok('OK to overwrite the file?', 2)``" -#: ../../tutorial/controlflow.rst:393 +#: ../../tutorial/controlflow.rst:394 msgid "" "or even giving all arguments: ``ask_ok('OK to overwrite the file?', 2, 'Come " "on, only yes or no!')``" msgstr "" +"給予所有引數:\\ ``ask_ok('OK to overwrite the file?', 2, 'Come on, only yes " +"or no!')``" -#: ../../tutorial/controlflow.rst:396 +#: ../../tutorial/controlflow.rst:397 msgid "" "This example also introduces the :keyword:`in` keyword. This tests whether " "or not a sequence contains a certain value." msgstr "" +"此例也使用了關鍵字 :keyword:`in`\\ ,用於測試序列中是否包含某個特定值。" -#: ../../tutorial/controlflow.rst:399 +#: ../../tutorial/controlflow.rst:400 msgid "" "The default values are evaluated at the point of function definition in the " "*defining* scope, so that ::" msgstr "" +"預設值是在函式定義當下,於\\ *定義*\\ 作用域中求值,所以:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:410 +#: ../../tutorial/controlflow.rst:411 msgid "will print ``5``." -msgstr "" +msgstr "將會輸出 ``5``\\ 。" -#: ../../tutorial/controlflow.rst:412 +#: ../../tutorial/controlflow.rst:413 msgid "" "**Important warning:** The default value is evaluated only once. This makes " "a difference when the default is a mutable object such as a list, " "dictionary, or instances of most classes. For example, the following " "function accumulates the arguments passed to it on subsequent calls::" msgstr "" +"\\ **重要警告**\\ :預設值只求值一次。當預設值為可變物件,例如 list、" +"dictionary(字典)或許多類別實例時,會產生不同的結果。例如,以下函式於後續呼" +"叫時會累積曾經傳遞的引數:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:425 +#: ../../tutorial/controlflow.rst:426 msgid "This will print ::" msgstr "" +"將會輸出:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:431 +#: ../../tutorial/controlflow.rst:432 msgid "" "If you don't want the default to be shared between subsequent calls, you can " "write the function like this instead::" -msgstr "" +msgstr "如果不想在後續呼叫之間共用預設值,應以如下方式編寫函式:" -#: ../../tutorial/controlflow.rst:444 +#: ../../tutorial/controlflow.rst:445 msgid "Keyword Arguments" -msgstr "" +msgstr "關鍵字引數" -#: ../../tutorial/controlflow.rst:446 +#: ../../tutorial/controlflow.rst:447 msgid "" "Functions can also be called using :term:`keyword arguments ` of the form ``kwarg=value``. For instance, the following " "function::" msgstr "" +"函式也可以使用\\ :term:`關鍵字引數 `\\ ,以 " +"``kwarg=value`` 的形式呼叫。舉例來說,以下函式:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:455 +#: ../../tutorial/controlflow.rst:456 msgid "" "accepts one required argument (``voltage``) and three optional arguments " "(``state``, ``action``, and ``type``). This function can be called in any " "of the following ways::" msgstr "" +"接受一個必選引數 (``voltage``) 和三個可選引數 (``state``,``action``,和 " +"``type``)。該函式可用下列任一方式呼叫:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:466 +#: ../../tutorial/controlflow.rst:467 msgid "but all the following calls would be invalid::" msgstr "" +"但以下呼叫方式都無效:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:473 +#: ../../tutorial/controlflow.rst:474 msgid "" "In a function call, keyword arguments must follow positional arguments. All " "the keyword arguments passed must match one of the arguments accepted by the " @@ -540,8 +573,15 @@ msgid "" "may receive a value more than once. Here's an example that fails due to this " "restriction::" msgstr "" +"函式呼叫時,關鍵字引數 (keyword argument) 必須在位置引數 (positional " +"argument) 後面。所有傳遞的關鍵字引數都必須匹配一個可被函式接受的引數(\\ " +"``actor`` 不是 ``parrot`` 函式的有效引數),而關鍵字引數的順序並不重要。此規" +"則也包括必選引數,(\\ ``parrot(voltage=1000)`` 也有效)。一個引數不可多次被" +"賦值,下面就是一個因此限制而失敗的例子:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:489 +#: ../../tutorial/controlflow.rst:490 msgid "" "When a final formal parameter of the form ``**name`` is present, it receives " "a dictionary (see :ref:`typesmapping`) containing all keyword arguments " @@ -551,26 +591,40 @@ msgid "" "positional arguments beyond the formal parameter list. (``*name`` must " "occur before ``**name``.) For example, if we define a function like this::" msgstr "" +"當最後一個形式參數 (formal parameter) 為 ``**name`` 形式時,它接收一個 " +"dictionary(字典,詳見 :ref:`typesmapping`\\ ),該字典包含所有可對應形式參數" +"以外的關鍵字引數。\\ ``**name`` 可以與 ``*name`` 形式參數(下一小節介紹)組合" +"使用,\\ ``*name`` 接收一個 :ref:`tuple `\\ ,該 tuple 包含形式參" +"數 list 之外的位置引數(\\ ``*name`` 必須出現在 ``**name`` 前面)。例如,若我" +"們定義這樣的函式:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:506 +#: ../../tutorial/controlflow.rst:507 msgid "It could be called like this::" msgstr "" +"它可以被如此呼叫:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:514 +#: ../../tutorial/controlflow.rst:515 msgid "and of course it would print:" msgstr "" +"輸出結果如下:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:527 +#: ../../tutorial/controlflow.rst:528 msgid "" "Note that the order in which the keyword arguments are printed is guaranteed " "to match the order in which they were provided in the function call." -msgstr "" +msgstr "注意,關鍵字引數的輸出順序與呼叫函式時被提供的順序必定一致。" -#: ../../tutorial/controlflow.rst:531 +#: ../../tutorial/controlflow.rst:532 msgid "Special parameters" -msgstr "" +msgstr "特殊參數" -#: ../../tutorial/controlflow.rst:533 +#: ../../tutorial/controlflow.rst:534 msgid "" "By default, arguments may be passed to a Python function either by position " "or explicitly by keyword. For readability and performance, it makes sense to " @@ -578,34 +632,41 @@ msgid "" "at the function definition to determine if items are passed by position, by " "position or keyword, or by keyword." msgstr "" +"在預設情況,引數能以位置或外顯的關鍵字傳遞给 Python 函式。為了程式的可讀性及" +"效能,限制引數的傳遞方式是合理的,如此,開發者只需查看函式定義,即可確定各項" +"目是按位置,按位置或關鍵字,還是按關鍵字傳遞。" -#: ../../tutorial/controlflow.rst:539 +#: ../../tutorial/controlflow.rst:540 msgid "A function definition may look like:" -msgstr "" +msgstr "函式定義可能如以下樣式:" -#: ../../tutorial/controlflow.rst:550 +#: ../../tutorial/controlflow.rst:551 msgid "" "where ``/`` and ``*`` are optional. If used, these symbols indicate the kind " "of parameter by how the arguments may be passed to the function: positional-" "only, positional-or-keyword, and keyword-only. Keyword parameters are also " "referred to as named parameters." msgstr "" +"``/`` 和 ``*`` 是可選的。這些符號若被使用,是表明引數被傳遞給函式的參數種類:" +"僅限位置、位置或關鍵字、僅限關鍵字。關鍵字參數也稱為附名參數 (named " +"parameters)。" -#: ../../tutorial/controlflow.rst:557 +#: ../../tutorial/controlflow.rst:558 msgid "Positional-or-Keyword Arguments" -msgstr "" +msgstr "位置或關鍵字引數 (Positional-or-Keyword Arguments)" -#: ../../tutorial/controlflow.rst:559 +#: ../../tutorial/controlflow.rst:560 msgid "" "If ``/`` and ``*`` are not present in the function definition, arguments may " "be passed to a function by position or by keyword." msgstr "" +"若函式定義中未使用 ``/`` 和 ``*`` 時,引數可以按位置或關鍵字傳遞給函式。" -#: ../../tutorial/controlflow.rst:564 +#: ../../tutorial/controlflow.rst:565 msgid "Positional-Only Parameters" -msgstr "" +msgstr "僅限位置參數 (Positional-Only Parameters)" -#: ../../tutorial/controlflow.rst:566 +#: ../../tutorial/controlflow.rst:567 msgid "" "Looking at this in a bit more detail, it is possible to mark certain " "parameters as *positional-only*. If *positional-only*, the parameters' order " @@ -615,100 +676,137 @@ msgid "" "parameters. If there is no ``/`` in the function definition, there are no " "positional-only parameters." msgstr "" +"此處再詳述一些細節,特定參數可以標記為\\ *僅限位置*\\ 。若參數為\\ *僅限位置*" +"\\ 時,它們的順序很重要,且這些參數不能用關鍵字傳遞。僅限位置參數必須放在 ``/" +"``\\ (斜線)之前。\\ ``/`` 用於在邏輯上分離僅限位置參數與其餘參數。如果函式" +"定義中沒有 ``/``\\ ,則表示沒有任何僅限位置參數。" -#: ../../tutorial/controlflow.rst:574 +#: ../../tutorial/controlflow.rst:575 msgid "" "Parameters following the ``/`` may be *positional-or-keyword* or *keyword-" "only*." -msgstr "" +msgstr "``/`` 後面的參數可以是\\ *位置或關鍵字*\\ 或\\ *僅限關鍵字*\\ 參數。" -#: ../../tutorial/controlflow.rst:578 +#: ../../tutorial/controlflow.rst:579 msgid "Keyword-Only Arguments" -msgstr "" +msgstr "僅限關鍵字引數 (Keyword-Only Arguments)" -#: ../../tutorial/controlflow.rst:580 +#: ../../tutorial/controlflow.rst:581 msgid "" "To mark parameters as *keyword-only*, indicating the parameters must be " "passed by keyword argument, place an ``*`` in the arguments list just before " "the first *keyword-only* parameter." msgstr "" +"要把參數標記為\\ *僅限關鍵字*\\ ,表明參數必須以關鍵字引數傳遞,必須在引數 " +"list 中第一個\\ *僅限關鍵字*\\ 參數前放上 ``*``\\ 。" -#: ../../tutorial/controlflow.rst:586 +#: ../../tutorial/controlflow.rst:587 msgid "Function Examples" -msgstr "" +msgstr "函式範例" -#: ../../tutorial/controlflow.rst:588 +#: ../../tutorial/controlflow.rst:589 msgid "" "Consider the following example function definitions paying close attention " "to the markers ``/`` and ``*``::" msgstr "" +"請看以下的函式定義範例,注意 ``/`` 和 ``*`` 記號:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:604 +#: ../../tutorial/controlflow.rst:605 msgid "" "The first function definition, ``standard_arg``, the most familiar form, " "places no restrictions on the calling convention and arguments may be passed " "by position or keyword::" msgstr "" +"第一個函式定義 ``standard_arg`` 是我們最熟悉的形式,對呼叫方式沒有任何限制," +"可以按位置或關鍵字傳遞引數:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:614 +#: ../../tutorial/controlflow.rst:615 msgid "" "The second function ``pos_only_arg`` is restricted to only use positional " "parameters as there is a ``/`` in the function definition::" msgstr "" +"第二個函式 ``pos_only_arg`` 的函式定義中有 ``/``\\ ,因此僅限使用位置參數:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:625 +#: ../../tutorial/controlflow.rst:626 msgid "" "The third function ``kwd_only_args`` only allows keyword arguments as " "indicated by a ``*`` in the function definition::" msgstr "" +"第三個函式 ``kwd_only_args`` 的函式定義透過 ``*`` 表明僅限關鍵字引數:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:636 +#: ../../tutorial/controlflow.rst:637 msgid "" "And the last uses all three calling conventions in the same function " "definition::" msgstr "" +"最後一個函式在同一個函式定義中,使用了全部三種呼叫方式:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:656 +#: ../../tutorial/controlflow.rst:657 msgid "" "Finally, consider this function definition which has a potential collision " "between the positional argument ``name`` and ``**kwds`` which has ``name`` " "as a key::" msgstr "" +"最後,請看這個函式定義,如果 ``**kwds`` 內有 ``name`` 這個鍵,可能與位置引數 " +"``name`` 產生潛在衝突:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:661 +#: ../../tutorial/controlflow.rst:662 msgid "" "There is no possible call that will make it return ``True`` as the keyword " -"``'name'`` will always to bind to the first parameter. For example::" +"``'name'`` will always bind to the first parameter. For example::" msgstr "" +"呼叫該函式不可能回傳 ``True``\\ ,因為關鍵字 ``'name'`` 永遠是連結在第一個參" +"數。例如:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:670 +#: ../../tutorial/controlflow.rst:671 msgid "" "But using ``/`` (positional only arguments), it is possible since it allows " "``name`` as a positional argument and ``'name'`` as a key in the keyword " "arguments::" msgstr "" +"使用 ``/``\\ (僅限位置引數)後,就可以了。函式定義會允許 ``name`` 當作位置引" +"數,而 ``'name'`` 也可以當作關鍵字引數中的鍵:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:677 +#: ../../tutorial/controlflow.rst:678 msgid "" "In other words, the names of positional-only parameters can be used in " "``**kwds`` without ambiguity." -msgstr "" +msgstr "換句話說,僅限位置參數的名稱可以在 ``**kwds`` 中使用,而不產生歧義。" -#: ../../tutorial/controlflow.rst:682 +#: ../../tutorial/controlflow.rst:683 msgid "Recap" -msgstr "" +msgstr "回顧" -#: ../../tutorial/controlflow.rst:684 +#: ../../tutorial/controlflow.rst:685 msgid "" "The use case will determine which parameters to use in the function " "definition::" msgstr "" +"此用例決定哪些參數可以用於函式定義:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:688 +#: ../../tutorial/controlflow.rst:689 msgid "As guidance:" -msgstr "" +msgstr "說明:" -#: ../../tutorial/controlflow.rst:690 +#: ../../tutorial/controlflow.rst:691 msgid "" "Use positional-only if you want the name of the parameters to not be " "available to the user. This is useful when parameter names have no real " @@ -716,33 +814,45 @@ msgid "" "is called or if you need to take some positional parameters and arbitrary " "keywords." msgstr "" +"如果不想讓使用者使用參數名稱,請使用僅限位置。當參數名稱沒有實際意義時,若你" +"想控制引數在函式呼叫的排列順序,或同時使用位置參數和任意關鍵字時,這種方式很" +"有用。" -#: ../../tutorial/controlflow.rst:695 +#: ../../tutorial/controlflow.rst:696 msgid "" "Use keyword-only when names have meaning and the function definition is more " "understandable by being explicit with names or you want to prevent users " "relying on the position of the argument being passed." msgstr "" +"當參數名稱有意義,且外顯的名稱可讓函式定義更易理解,或是你不希望使用者依賴引" +"數被傳遞時的位置時,請使用僅限關鍵字。" -#: ../../tutorial/controlflow.rst:698 +#: ../../tutorial/controlflow.rst:699 msgid "" "For an API, use positional-only to prevent breaking API changes if the " "parameter's name is modified in the future." msgstr "" +"對於應用程式介面 (API),使用僅限位置,以防止未來參數名稱被修改時造成 API 的中" +"斷性變更。" -#: ../../tutorial/controlflow.rst:704 +#: ../../tutorial/controlflow.rst:705 msgid "Arbitrary Argument Lists" -msgstr "" +msgstr "任意引數串列 (Arbitrary Argument Lists)" -#: ../../tutorial/controlflow.rst:709 +#: ../../tutorial/controlflow.rst:710 msgid "" "Finally, the least frequently used option is to specify that a function can " "be called with an arbitrary number of arguments. These arguments will be " "wrapped up in a tuple (see :ref:`tut-tuples`). Before the variable number " "of arguments, zero or more normal arguments may occur. ::" msgstr "" +"最後,有個較不常用的選項,是規定函式被呼叫時,可以使用任意數量的引數。這些引" +"數會被包裝進一個 tuple 中(詳見 :ref:`tut-tuples`\\ )。在可變數量的引數之" +"前,可能有零個或多個普通引數:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:718 +#: ../../tutorial/controlflow.rst:719 msgid "" "Normally, these ``variadic`` arguments will be last in the list of formal " "parameters, because they scoop up all remaining input arguments that are " @@ -750,12 +860,18 @@ msgid "" "``*args`` parameter are 'keyword-only' arguments, meaning that they can only " "be used as keywords rather than positional arguments. ::" msgstr "" +"通常,這些 ``variadic``\\ (可變的)引數會出現在形式參數 list 的最末端,這樣" +"它們就可以把所有傳遞給函式的剩餘輸入引數都撈起來。出現在 ``*args`` 參數後面的" +"任何形式參數必須是「僅限關鍵字」引數,意即它們只能作為關鍵字引數,而不能用作" +"位置引數。\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:735 +#: ../../tutorial/controlflow.rst:736 msgid "Unpacking Argument Lists" -msgstr "" +msgstr "拆解引數串列(Unpacking Argument Lists)" -#: ../../tutorial/controlflow.rst:737 +#: ../../tutorial/controlflow.rst:738 msgid "" "The reverse situation occurs when the arguments are already in a list or " "tuple but need to be unpacked for a function call requiring separate " @@ -764,18 +880,27 @@ msgid "" "separately, write the function call with the ``*``\\ -operator to unpack " "the arguments out of a list or tuple::" msgstr "" +"當引數們已經存在一個 list 或 tuple 裡,但為了滿足一個需要個別位置引數的函式呼" +"叫,而去拆解它們時,情況就剛好相反。例如,內建的 :func:`range` 函式要求分離" +"的 *start* 和 *stop* 引數。如果這些引數不是分離的,則要在呼叫函式時,用 " +"``*`` 運算子把引數們從 list 或 tuple 中拆解出來:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:753 +#: ../../tutorial/controlflow.rst:754 msgid "" "In the same fashion, dictionaries can deliver keyword arguments with the " "``**``\\ -operator::" msgstr "" +"同樣地,dictionary(字典)可以用 ``**`` 運算子傳遞關鍵字引數:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:769 +#: ../../tutorial/controlflow.rst:770 msgid "Lambda Expressions" -msgstr "" +msgstr "Lambda 運算式" -#: ../../tutorial/controlflow.rst:771 +#: ../../tutorial/controlflow.rst:772 msgid "" "Small anonymous functions can be created with the :keyword:`lambda` keyword. " "This function returns the sum of its two arguments: ``lambda a, b: a+b``. " @@ -785,24 +910,34 @@ msgid "" "definitions, lambda functions can reference variables from the containing " "scope::" msgstr "" +":keyword:`lambda` 關鍵字用於建立小巧的匿名函式。\\ ``lambda a, b: a+b`` 函式" +"返回兩個引數的和。Lambda 函式可用於任何需要函數物件的地方。在語法上,它們被限" +"定只能是單一運算式。在語義上,它就是一個普通函式定義的語法糖 (syntactic " +"sugar)。與巢狀函式定義一樣,lambda 函式可以從包含它的作用域中引用變數:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:788 +#: ../../tutorial/controlflow.rst:789 msgid "" "The above example uses a lambda expression to return a function. Another " "use is to pass a small function as an argument::" msgstr "" +"上面的例子用 lambda 運算式回傳了一個函式。另外的用法是傳遞一個小函式當作引" +"數:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:800 +#: ../../tutorial/controlflow.rst:801 msgid "Documentation Strings" -msgstr "說明文件字串" +msgstr "說明文件字串 (Documentation Strings)" -#: ../../tutorial/controlflow.rst:807 +#: ../../tutorial/controlflow.rst:808 msgid "" "Here are some conventions about the content and formatting of documentation " "strings." -msgstr "" +msgstr "以下是關於說明文件字串內容和格式的慣例。" -#: ../../tutorial/controlflow.rst:810 +#: ../../tutorial/controlflow.rst:811 msgid "" "The first line should always be a short, concise summary of the object's " "purpose. For brevity, it should not explicitly state the object's name or " @@ -810,16 +945,21 @@ msgid "" "to be a verb describing a function's operation). This line should begin " "with a capital letter and end with a period." msgstr "" +"第一行都是一段關於此物件目的之簡短摘要。為保持簡潔,不應在這裡外顯地陳述物件" +"的名稱或型別,因為有其他方法可以達到相同目的(除非該名稱剛好是一個描述函式運" +"算的動詞)。這一行應以大寫字母開頭,以句號結尾。" -#: ../../tutorial/controlflow.rst:816 +#: ../../tutorial/controlflow.rst:817 msgid "" "If there are more lines in the documentation string, the second line should " "be blank, visually separating the summary from the rest of the description. " "The following lines should be one or more paragraphs describing the object's " "calling conventions, its side effects, etc." msgstr "" +"文件字串為多行時,第二行應為空白行,在視覺上將摘要與其餘描述分開。後面幾行可" +"包含一或多個段落,描述此物件的呼叫慣例、副作用等。" -#: ../../tutorial/controlflow.rst:821 +#: ../../tutorial/controlflow.rst:822 msgid "" "The Python parser does not strip indentation from multi-line string literals " "in Python, so tools that process documentation have to strip indentation if " @@ -833,23 +973,35 @@ msgid "" "all their leading whitespace should be stripped. Equivalence of whitespace " "should be tested after expansion of tabs (to 8 spaces, normally)." msgstr "" +"Python 剖析器不會去除 Python 中多行字串的縮排,因此,處理說明文件的工具應在必" +"要時去除縮排。這項操作遵循以下慣例:在字串第一行\\ *之後*\\ 的第一個非空白行" +"決定了整個說明文件字串的縮排量(不能用第一行的縮排,因為它通常與字串的開頭引" +"號們相鄰,其縮排在字串文字中並不明顯),然後,所有字串行開頭處與此縮排量「等" +"價」的空白字元會被去除。不應出現比上述縮進量更少的字串行,但若真的出現了,這" +"些行的全部前導空白字元都應被去除。展開欄標 (tab) 後(通常為八個空格),應測試" +"空白字元量是否等價。" -#: ../../tutorial/controlflow.rst:833 +#: ../../tutorial/controlflow.rst:834 msgid "Here is an example of a multi-line docstring::" msgstr "" +"下面是多行說明字串的一個範例:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:851 +#: ../../tutorial/controlflow.rst:852 msgid "Function Annotations" -msgstr "" +msgstr "函式註解 (Function Annotations)" -#: ../../tutorial/controlflow.rst:859 +#: ../../tutorial/controlflow.rst:860 msgid "" ":ref:`Function annotations ` are completely optional metadata " "information about the types used by user-defined functions (see :pep:`3107` " "and :pep:`484` for more information)." msgstr "" +":ref:`函式註解 `\\ 是可選的元資料(metadata)資訊,描述使用者定義函" +"式所使用的型別(更多資訊詳見 :pep:`3107` 和 :pep:`484`\\ )。" -#: ../../tutorial/controlflow.rst:863 +#: ../../tutorial/controlflow.rst:864 msgid "" ":term:`Annotations ` are stored in the :attr:" "`__annotations__` attribute of the function as a dictionary and have no " @@ -858,14 +1010,22 @@ msgid "" "the value of the annotation. Return annotations are defined by a literal ``-" ">``, followed by an expression, between the parameter list and the colon " "denoting the end of the :keyword:`def` statement. The following example has " -"a positional argument, a keyword argument, and the return value annotated::" -msgstr "" +"a required argument, an optional argument, and the return value annotated::" +msgstr "" +":term:`註解 `\\ 以 dictionary(字典)的形式存放在函式" +"的 :attr:`__annotations__` 屬性中,且不會影響函式的任何其他部分。參數註解的定" +"義方式是在參數名稱後加一個冒號,冒號後面跟著一個對註解求值的運算式。回傳註解" +"的定義方式是在參數 list 和 :keyword:`def` 陳述式結尾的冒號中間,用一個 ``-" +">`` 文字接著一個運算式。以下範例有一個必選引數、一個可選引數,以及被註解的回" +"傳值:\n" +"\n" +"::" -#: ../../tutorial/controlflow.rst:885 +#: ../../tutorial/controlflow.rst:886 msgid "Intermezzo: Coding Style" -msgstr "" +msgstr "間奏曲:編碼樣式 (Coding Style)" -#: ../../tutorial/controlflow.rst:890 +#: ../../tutorial/controlflow.rst:891 msgid "" "Now that you are about to write longer, more complex pieces of Python, it is " "a good time to talk about *coding style*. Most languages can be written (or " @@ -873,88 +1033,111 @@ msgid "" "others. Making it easy for others to read your code is always a good idea, " "and adopting a nice coding style helps tremendously for that." msgstr "" +"現在你即將要寫更長、更複雜的 Python 程式,是時候討論一下\\ *編碼樣式*\\ 了。" +"大多數語言都能以不同的樣式被書寫(或更精確地說,被\\ *格式化*\\ ),而有些樣" +"式比其他的更具可讀性。能讓其他人輕鬆閱讀你的程式碼永遠是一個好主意,而使用優" +"良的編碼樣式對此有極大的幫助。" -#: ../../tutorial/controlflow.rst:896 +#: ../../tutorial/controlflow.rst:897 msgid "" "For Python, :pep:`8` has emerged as the style guide that most projects " "adhere to; it promotes a very readable and eye-pleasing coding style. Every " "Python developer should read it at some point; here are the most important " "points extracted for you:" msgstr "" +"對於 Python,大多數的專案都遵循 :pep:`8` 的樣式指南;它推行的編碼樣式相當可讀" +"且賞心悅目。每個 Python 開發者都應該花點時間研讀;這裡是該指南的核心重點:" -#: ../../tutorial/controlflow.rst:901 +#: ../../tutorial/controlflow.rst:902 msgid "Use 4-space indentation, and no tabs." -msgstr "" +msgstr "用 4 個空格縮排,不要用欄標 (tab)。" -#: ../../tutorial/controlflow.rst:903 +#: ../../tutorial/controlflow.rst:904 msgid "" "4 spaces are a good compromise between small indentation (allows greater " "nesting depth) and large indentation (easier to read). Tabs introduce " "confusion, and are best left out." msgstr "" +"4 個空格是小縮排(容許更大的巢套深度)和大縮排(較易閱讀)之間的折衷方案。欄" +"標會造成混亂,最好別用。" -#: ../../tutorial/controlflow.rst:907 +#: ../../tutorial/controlflow.rst:908 msgid "Wrap lines so that they don't exceed 79 characters." -msgstr "" +msgstr "換行,使一行不超過 79 個字元。" -#: ../../tutorial/controlflow.rst:909 +#: ../../tutorial/controlflow.rst:910 msgid "" "This helps users with small displays and makes it possible to have several " "code files side-by-side on larger displays." msgstr "" +"換行能讓使用小顯示器的使用者方便閱讀,也可以在較大顯示器上並排陳列多個程式碼" +"檔案。" -#: ../../tutorial/controlflow.rst:912 +#: ../../tutorial/controlflow.rst:913 msgid "" "Use blank lines to separate functions and classes, and larger blocks of code " "inside functions." -msgstr "" +msgstr "用空行分隔函式和 class(類別),及函式內較大塊的程式碼。" -#: ../../tutorial/controlflow.rst:915 +#: ../../tutorial/controlflow.rst:916 msgid "When possible, put comments on a line of their own." -msgstr "" +msgstr "如果可以,把說明放在單獨一行。" -#: ../../tutorial/controlflow.rst:917 +#: ../../tutorial/controlflow.rst:918 msgid "Use docstrings." -msgstr "" +msgstr "使用說明字串。" -#: ../../tutorial/controlflow.rst:919 +#: ../../tutorial/controlflow.rst:920 msgid "" "Use spaces around operators and after commas, but not directly inside " "bracketing constructs: ``a = f(1, 2) + g(3, 4)``." msgstr "" +"運算子前後、逗號後要加空格,但不要直接放在括號內側:\\ ``a = f(1, 2) + g(3, " +"4)``\\ 。" -#: ../../tutorial/controlflow.rst:922 +#: ../../tutorial/controlflow.rst:923 msgid "" "Name your classes and functions consistently; the convention is to use " "``UpperCamelCase`` for classes and ``lowercase_with_underscores`` for " "functions and methods. Always use ``self`` as the name for the first method " "argument (see :ref:`tut-firstclasses` for more on classes and methods)." msgstr "" +"Class 和函式的命名樣式要一致;按慣例,命名 class 用 ``UpperCamelCase``\\ (駝" +"峰式大小寫),命名函式與 method 用 ``lowercase_with_underscores``\\ (小寫加" +"底線)。永遠用 ``self`` 作為第一個 method 引數的名稱(關於 class 和 method," +"詳見 :ref:`tut-firstclasses`\\ )。" -#: ../../tutorial/controlflow.rst:927 +#: ../../tutorial/controlflow.rst:928 msgid "" "Don't use fancy encodings if your code is meant to be used in international " "environments. Python's default, UTF-8, or even plain ASCII work best in any " "case." msgstr "" +"若程式碼是為了用於國際環境時,不要用花俏的編碼。Python 預設的 UTF-8 或甚至普" +"通的 ASCII,就可以勝任各種情況。" -#: ../../tutorial/controlflow.rst:931 +#: ../../tutorial/controlflow.rst:932 msgid "" "Likewise, don't use non-ASCII characters in identifiers if there is only the " "slightest chance people speaking a different language will read or maintain " "the code." msgstr "" +"同樣地,若不同語言使用者閱讀或維護程式碼的可能性微乎其微,就不要在識別碼 " +"(identifier) 中使用非 ASCII 字元。" -#: ../../tutorial/controlflow.rst:937 +#: ../../tutorial/controlflow.rst:938 msgid "Footnotes" -msgstr "註解" +msgstr "註腳" -#: ../../tutorial/controlflow.rst:938 +#: ../../tutorial/controlflow.rst:939 msgid "" "Actually, *call by object reference* would be a better description, since if " "a mutable object is passed, the caller will see any changes the callee makes " "to it (items inserted into a list)." msgstr "" +"實際上,\\ *傳物件參照呼叫 (call by object reference)* 的說法可能較為貼切。因" +"為,若傳遞的是一個可變物件時,呼叫者將看得見被呼叫物件做出的任何改變(例如被" +"插入 list 內的新項目)。" #~ msgid "" #~ "If you need to modify the sequence you are iterating over while inside " From 8fd7f530371803c524c8501c4aacd72c2cf1fa03 Mon Sep 17 00:00:00 2001 From: Steven Hsu <81967953+StevenHsuYL@users.noreply.github.com> Date: Sun, 23 May 2021 22:25:08 +0800 Subject: [PATCH 2/4] Update "Footnotes" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "註解" --- tutorial/controlflow.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorial/controlflow.po b/tutorial/controlflow.po index b6c5bc9eab..efc1c6a529 100644 --- a/tutorial/controlflow.po +++ b/tutorial/controlflow.po @@ -12,7 +12,7 @@ msgstr "" "Project-Id-Version: Python 3.9\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-05-18 12:27+0800\n" -"PO-Revision-Date: 2021-05-21 09:40+0800\n" +"PO-Revision-Date: 2021-05-23 22:23+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -1127,7 +1127,7 @@ msgstr "" #: ../../tutorial/controlflow.rst:938 msgid "Footnotes" -msgstr "註腳" +msgstr "註解" #: ../../tutorial/controlflow.rst:939 msgid "" From 01cd7e087dbf7910a43b9fb87ff6946d12043c1c Mon Sep 17 00:00:00 2001 From: Steven Hsu <81967953+StevenHsuYL@users.noreply.github.com> Date: Mon, 24 May 2021 18:31:57 +0800 Subject: [PATCH 3/4] Revised controlflow.po Fix all suggested translation. --- tutorial/controlflow.po | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tutorial/controlflow.po b/tutorial/controlflow.po index efc1c6a529..4735d1822e 100644 --- a/tutorial/controlflow.po +++ b/tutorial/controlflow.po @@ -12,7 +12,7 @@ msgstr "" "Project-Id-Version: Python 3.9\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-05-18 12:27+0800\n" -"PO-Revision-Date: 2021-05-23 22:23+0800\n" +"PO-Revision-Date: 2021-05-24 18:28+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -77,8 +77,8 @@ msgid "" msgstr "" "在 Python 中的 :keyword:`for` 陳述式有點不同於在 C 或 Pascal 中的慣用方式。相" "較於只能疊代 (iterate) 一個等差數列(如 Pascal),或給予使用者定義疊代步驟與" -"暫停條件(如 C),Python 的 :keyword:`!for` 陳述式疊代任何序列(list 或者字" -"串)的項目,項目的順序與他們出現在序列中的順序相同。例如(無意雙關):\n" +"終止條件(如 C),Python 的 :keyword:`!for` 陳述式疊代任何序列(list 或者字" +"串)的元素,順序與它們出現在序列中的順序相同。例如(無意雙關):\n" "\n" "::" @@ -89,7 +89,7 @@ msgid "" "loop over a copy of the collection or to create a new collection::" msgstr "" "在疊代一個集合的同時修改該集合的內容,很難獲取想要的結果。比較直觀的替代方" -"式,是疊代該集合的副本,或創建一個新的集合:\n" +"式,是疊代該集合的副本,或建立一個新的集合:\n" "\n" "::" @@ -279,7 +279,7 @@ msgid "" "ignored::" msgstr "" ":keyword:`pass` 亦可作為一個函式或條件判斷主體的預留位置,在你撰寫新的程式碼" -"時讓你保持在更抽象的思維層次。:keyword:`!pass` 可以直接被略過:\n" +"時讓你保持在更抽象的思維層次。\\ :keyword:`!pass` 會直接被忽略:\n" "\n" "::" @@ -304,8 +304,7 @@ msgid "" "next line, and must be indented." msgstr "" "關鍵字 :keyword:`def` 介紹一個函式的\\ *定義*\\ 。它之後必須連著該函式的名稱" -"和置於括號之中的形式參數 (parameter) 串列。自下一行起,所有縮排的陳述式成為該" -"函式的主體。" +"和置於括號之中的一串參數。自下一行起,所有縮排的陳述式成為該函式的主體。" #: ../../tutorial/controlflow.rst:277 msgid "" @@ -317,11 +316,11 @@ msgid "" "through code; it's good practice to include docstrings in code that you " "write, so make a habit of it." msgstr "" -"一個函式的第一個陳述式可以是一個字串文字;該字串文字被視為該函式的說明文件字" +"一個函式的第一個陳述式可以是一個字串文本;該字串文本被視為該函式的說明文件字" "串,即 :dfn:`docstring`\\ 。(關於 docstring 的細節請參見\\ :ref:`tut-" "docstrings`\\ 段落。)有些工具可以使用 docstring 來自動產生線上或可列印的文" -"件,或讓使用者能以互動方式瀏覽原始碼。在原始碼中加入 docstring 是個好慣例,應" -"該養成這樣的習慣。" +"件,或讓使用者能以互動的方式在原始碼中瀏覽文件。在原始碼中加入 docstring 是個" +"好慣例,應該養成這樣的習慣。" #: ../../tutorial/controlflow.rst:284 msgid "" From 2e05dee2954cfe6a493c6735a3839a054b3947be Mon Sep 17 00:00:00 2001 From: Steven Hsu <81967953+StevenHsuYL@users.noreply.github.com> Date: Tue, 1 Jun 2021 22:44:54 +0800 Subject: [PATCH 4/4] Update controlflow.po Fix all suggestions above. --- tutorial/controlflow.po | 120 ++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 61 deletions(-) diff --git a/tutorial/controlflow.po b/tutorial/controlflow.po index 4735d1822e..2555736843 100644 --- a/tutorial/controlflow.po +++ b/tutorial/controlflow.po @@ -12,7 +12,7 @@ msgstr "" "Project-Id-Version: Python 3.9\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-05-18 12:27+0800\n" -"PO-Revision-Date: 2021-05-24 18:28+0800\n" +"PO-Revision-Date: 2021-06-01 22:43+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -383,9 +383,8 @@ msgid "" msgstr "" "如果你是來自別的語言,你可能不同意 ``fib`` 是個函式,而是個程序 (procedure)," "因為它並沒有回傳值。實際上,即使一個函式缺少一個 :keyword:`return` 陳述式,它" -"亦有一個固定的回傳值。這個值稱為 ``None``\\ (它是一個內建名稱)。如果 " -"``None`` 是唯一的回傳值,一般不會被直譯器顯示。你可以使用 :func:`print` 來看" -"到它:\n" +"亦有一個固定的回傳值。這個值稱為 ``None``\\ (它是一個內建名稱)。在直譯器中" +"單獨使用 ``None`` 時,通常不會被顯示。你可以使用 :func:`print` 來看到它:\n" "\n" "::" @@ -467,13 +466,13 @@ msgstr "該函式可以用以下幾種方式被呼叫:" #: ../../tutorial/controlflow.rst:390 msgid "" "giving only the mandatory argument: ``ask_ok('Do you really want to quit?')``" -msgstr "只給必選引數:\\ ``ask_ok('Do you really want to quit?')``" +msgstr "只給必要引數:\\ ``ask_ok('Do you really want to quit?')``" #: ../../tutorial/controlflow.rst:392 msgid "" "giving one of the optional arguments: ``ask_ok('OK to overwrite the file?', " "2)``" -msgstr "給予一個可選引數:\\ ``ask_ok('OK to overwrite the file?', 2)``" +msgstr "給予一個選擇性引數:\\ ``ask_ok('OK to overwrite the file?', 2)``" #: ../../tutorial/controlflow.rst:394 msgid "" @@ -495,7 +494,7 @@ msgid "" "The default values are evaluated at the point of function definition in the " "*defining* scope, so that ::" msgstr "" -"預設值是在函式定義當下,於\\ *定義*\\ 作用域中求值,所以:\n" +"預設值是在函式定義當下,於\\ *定義時*\\ 的作用域中求值,所以:\n" "\n" "::" @@ -550,7 +549,7 @@ msgid "" "(``state``, ``action``, and ``type``). This function can be called in any " "of the following ways::" msgstr "" -"接受一個必選引數 (``voltage``) 和三個可選引數 (``state``,``action``,和 " +"接受一個必要引數 (``voltage``) 和三個選擇性引數 (``state``,``action``,和 " "``type``)。該函式可用下列任一方式呼叫:\n" "\n" "::" @@ -575,8 +574,8 @@ msgstr "" "函式呼叫時,關鍵字引數 (keyword argument) 必須在位置引數 (positional " "argument) 後面。所有傳遞的關鍵字引數都必須匹配一個可被函式接受的引數(\\ " "``actor`` 不是 ``parrot`` 函式的有效引數),而關鍵字引數的順序並不重要。此規" -"則也包括必選引數,(\\ ``parrot(voltage=1000)`` 也有效)。一個引數不可多次被" -"賦值,下面就是一個因此限制而失敗的例子:\n" +"則也包括必要引數,(\\ ``parrot(voltage=1000)`` 也有效)。一個引數不可多次被" +"賦值,下面就是一個因此限制而無效的例子:\n" "\n" "::" @@ -590,12 +589,11 @@ msgid "" "positional arguments beyond the formal parameter list. (``*name`` must " "occur before ``**name``.) For example, if we define a function like this::" msgstr "" -"當最後一個形式參數 (formal parameter) 為 ``**name`` 形式時,它接收一個 " -"dictionary(字典,詳見 :ref:`typesmapping`\\ ),該字典包含所有可對應形式參數" -"以外的關鍵字引數。\\ ``**name`` 可以與 ``*name`` 形式參數(下一小節介紹)組合" -"使用,\\ ``*name`` 接收一個 :ref:`tuple `\\ ,該 tuple 包含形式參" -"數 list 之外的位置引數(\\ ``*name`` 必須出現在 ``**name`` 前面)。例如,若我" -"們定義這樣的函式:\n" +"當最後一個參數為 ``**name`` 形式時,它接收一個 dictionary(字典,詳見 :ref:" +"`typesmapping`\\ ),該字典包含所有可對應形式參數以外的關鍵字引數。\\ " +"``**name`` 可以與 ``*name`` 參數(下一小節介紹)組合使用,\\ ``*name`` 接收一" +"個 :ref:`tuple `\\ ,該 tuple 包含一般參數以外的位置引數(\\ " +"``*name`` 必須出現在 ``**name`` 前面)。例如,若我們定義這樣的函式:\n" "\n" "::" @@ -631,9 +629,9 @@ msgid "" "at the function definition to determine if items are passed by position, by " "position or keyword, or by keyword." msgstr "" -"在預設情況,引數能以位置或外顯的關鍵字傳遞给 Python 函式。為了程式的可讀性及" -"效能,限制引數的傳遞方式是合理的,如此,開發者只需查看函式定義,即可確定各項" -"目是按位置,按位置或關鍵字,還是按關鍵字傳遞。" +"在預設情況,引數能以位置或明確地以關鍵字傳遞给 Python 函式。為了程式的可讀性" +"及效能,限制引數的傳遞方式是合理的,如此,開發者只需查看函式定義,即可確定各" +"項目是按位置,按位置或關鍵字,還是按關鍵字傳遞。" #: ../../tutorial/controlflow.rst:540 msgid "A function definition may look like:" @@ -646,8 +644,8 @@ msgid "" "only, positional-or-keyword, and keyword-only. Keyword parameters are also " "referred to as named parameters." msgstr "" -"``/`` 和 ``*`` 是可選的。這些符號若被使用,是表明引數被傳遞給函式的參數種類:" -"僅限位置、位置或關鍵字、僅限關鍵字。關鍵字參數也稱為附名參數 (named " +"``/`` 和 ``*`` 是選擇性的。這些符號若被使用,是表明引數被傳遞給函式的參數種" +"類:僅限位置、位置或關鍵字、僅限關鍵字。關鍵字參數也稱為附名參數 (named " "parameters)。" #: ../../tutorial/controlflow.rst:558 @@ -677,7 +675,7 @@ msgid "" msgstr "" "此處再詳述一些細節,特定參數可以標記為\\ *僅限位置*\\ 。若參數為\\ *僅限位置*" "\\ 時,它們的順序很重要,且這些參數不能用關鍵字傳遞。僅限位置參數必須放在 ``/" -"``\\ (斜線)之前。\\ ``/`` 用於在邏輯上分離僅限位置參數與其餘參數。如果函式" +"``\\ (斜線)之前。\\ ``/`` 用於在邏輯上分開僅限位置參數與其餘參數。如果函式" "定義中沒有 ``/``\\ ,則表示沒有任何僅限位置參數。" #: ../../tutorial/controlflow.rst:575 @@ -696,8 +694,8 @@ msgid "" "passed by keyword argument, place an ``*`` in the arguments list just before " "the first *keyword-only* parameter." msgstr "" -"要把參數標記為\\ *僅限關鍵字*\\ ,表明參數必須以關鍵字引數傳遞,必須在引數 " -"list 中第一個\\ *僅限關鍵字*\\ 參數前放上 ``*``\\ 。" +"要把參數標記為\\ *僅限關鍵字*\\ ,表明參數必須以關鍵字引數傳遞,必須在引數列" +"表中第一個\\ *僅限關鍵字*\\ 參數前放上 ``*``\\ 。" #: ../../tutorial/controlflow.rst:587 msgid "Function Examples" @@ -823,7 +821,7 @@ msgid "" "understandable by being explicit with names or you want to prevent users " "relying on the position of the argument being passed." msgstr "" -"當參數名稱有意義,且外顯的名稱可讓函式定義更易理解,或是你不希望使用者依賴引" +"當參數名稱有意義,且明確的名稱可讓函式定義更易理解,或是你不希望使用者依賴引" "數被傳遞時的位置時,請使用僅限關鍵字。" #: ../../tutorial/controlflow.rst:699 @@ -836,7 +834,7 @@ msgstr "" #: ../../tutorial/controlflow.rst:705 msgid "Arbitrary Argument Lists" -msgstr "任意引數串列 (Arbitrary Argument Lists)" +msgstr "任意引數列表 (Arbitrary Argument Lists)" #: ../../tutorial/controlflow.rst:710 msgid "" @@ -859,16 +857,16 @@ msgid "" "``*args`` parameter are 'keyword-only' arguments, meaning that they can only " "be used as keywords rather than positional arguments. ::" msgstr "" -"通常,這些 ``variadic``\\ (可變的)引數會出現在形式參數 list 的最末端,這樣" -"它們就可以把所有傳遞給函式的剩餘輸入引數都撈起來。出現在 ``*args`` 參數後面的" -"任何形式參數必須是「僅限關鍵字」引數,意即它們只能作為關鍵字引數,而不能用作" -"位置引數。\n" +"通常,這些 ``variadic``\\ (可變的)引數會出現在參數列表的最末端,這樣它們就" +"可以把所有傳遞給函式的剩餘輸入引數都撈起來。出現在 ``*args`` 參數後面的任何參" +"數必須是「僅限關鍵字」引數,意即它們只能作為關鍵字引數,而不能用作位置引" +"數。\n" "\n" "::" #: ../../tutorial/controlflow.rst:736 msgid "Unpacking Argument Lists" -msgstr "拆解引數串列(Unpacking Argument Lists)" +msgstr "拆解引數列表(Unpacking Argument Lists)" #: ../../tutorial/controlflow.rst:738 msgid "" @@ -880,8 +878,8 @@ msgid "" "the arguments out of a list or tuple::" msgstr "" "當引數們已經存在一個 list 或 tuple 裡,但為了滿足一個需要個別位置引數的函式呼" -"叫,而去拆解它們時,情況就剛好相反。例如,內建的 :func:`range` 函式要求分離" -"的 *start* 和 *stop* 引數。如果這些引數不是分離的,則要在呼叫函式時,用 " +"叫,而去拆解它們時,情況就剛好相反。例如,內建的 :func:`range` 函式要求分開" +"的 *start* 和 *stop* 引數。如果這些引數不是分開的,則要在呼叫函式時,用 " "``*`` 運算子把引數們從 list 或 tuple 中拆解出來:\n" "\n" "::" @@ -944,7 +942,7 @@ msgid "" "to be a verb describing a function's operation). This line should begin " "with a capital letter and end with a period." msgstr "" -"第一行都是一段關於此物件目的之簡短摘要。為保持簡潔,不應在這裡外顯地陳述物件" +"第一行都是一段關於此物件目的之簡短摘要。為保持簡潔,不應在這裡明確地陳述物件" "的名稱或型別,因為有其他方法可以達到相同目的(除非該名稱剛好是一個描述函式運" "算的動詞)。這一行應以大寫字母開頭,以句號結尾。" @@ -972,13 +970,13 @@ msgid "" "all their leading whitespace should be stripped. Equivalence of whitespace " "should be tested after expansion of tabs (to 8 spaces, normally)." msgstr "" -"Python 剖析器不會去除 Python 中多行字串的縮排,因此,處理說明文件的工具應在必" -"要時去除縮排。這項操作遵循以下慣例:在字串第一行\\ *之後*\\ 的第一個非空白行" -"決定了整個說明文件字串的縮排量(不能用第一行的縮排,因為它通常與字串的開頭引" -"號們相鄰,其縮排在字串文字中並不明顯),然後,所有字串行開頭處與此縮排量「等" -"價」的空白字元會被去除。不應出現比上述縮進量更少的字串行,但若真的出現了,這" -"些行的全部前導空白字元都應被去除。展開欄標 (tab) 後(通常為八個空格),應測試" -"空白字元量是否等價。" +"Python 剖析器 (parser) 不會去除 Python 中多行字串的縮排,因此,處理說明文件的" +"工具應在必要時去除縮排。這項操作遵循以下慣例:在字串第一行\\ *之後*\\ 的第一" +"個非空白行決定了整個說明文件字串的縮排量(不能用第一行的縮排,因為它通常與字" +"串的開頭引號們相鄰,其縮排在字串文本中並不明顯),然後,所有字串行開頭處與此" +"縮排量「等價」的空白字元會被去除。不應出現比上述縮進量更少的字串行,但若真的" +"出現了,這些行的全部前導空白字元都應被去除。展開 tab 鍵後(通常為八個空格)," +"應測試空白字元量是否等價。" #: ../../tutorial/controlflow.rst:834 msgid "Here is an example of a multi-line docstring::" @@ -989,7 +987,7 @@ msgstr "" #: ../../tutorial/controlflow.rst:852 msgid "Function Annotations" -msgstr "函式註解 (Function Annotations)" +msgstr "函式註釋 (Function Annotations)" #: ../../tutorial/controlflow.rst:860 msgid "" @@ -997,8 +995,8 @@ msgid "" "information about the types used by user-defined functions (see :pep:`3107` " "and :pep:`484` for more information)." msgstr "" -":ref:`函式註解 `\\ 是可選的元資料(metadata)資訊,描述使用者定義函" -"式所使用的型別(更多資訊詳見 :pep:`3107` 和 :pep:`484`\\ )。" +":ref:`函式註釋 `\\ 是選擇性的元資料(metadata)資訊,描述使用者定義" +"函式所使用的型別(更多資訊詳見 :pep:`3107` 和 :pep:`484`\\ )。" #: ../../tutorial/controlflow.rst:864 msgid "" @@ -1011,18 +1009,18 @@ msgid "" "denoting the end of the :keyword:`def` statement. The following example has " "a required argument, an optional argument, and the return value annotated::" msgstr "" -":term:`註解 `\\ 以 dictionary(字典)的形式存放在函式" -"的 :attr:`__annotations__` 屬性中,且不會影響函式的任何其他部分。參數註解的定" -"義方式是在參數名稱後加一個冒號,冒號後面跟著一個對註解求值的運算式。回傳註解" -"的定義方式是在參數 list 和 :keyword:`def` 陳述式結尾的冒號中間,用一個 ``-" -">`` 文字接著一個運算式。以下範例有一個必選引數、一個可選引數,以及被註解的回" -"傳值:\n" +":term:`註釋 `\\ 以 dictionary(字典)的形式存放在函式" +"的 :attr:`__annotations__` 屬性中,且不會影響函式的任何其他部分。參數註釋的定" +"義方式是在參數名稱後加一個冒號,冒號後面跟著一個對註釋求值的運算式。回傳註釋" +"的定義方式是在參數列表和 :keyword:`def` 陳述式結尾的冒號中間,用一個 ``->`` " +"文字接著一個運算式。以下範例註釋了一個必要引數、一個選擇性引數,以及回傳" +"值:\n" "\n" "::" #: ../../tutorial/controlflow.rst:886 msgid "Intermezzo: Coding Style" -msgstr "間奏曲:編碼樣式 (Coding Style)" +msgstr "間奏曲:程式碼風格 (Coding Style)" #: ../../tutorial/controlflow.rst:891 msgid "" @@ -1049,7 +1047,7 @@ msgstr "" #: ../../tutorial/controlflow.rst:902 msgid "Use 4-space indentation, and no tabs." -msgstr "用 4 個空格縮排,不要用欄標 (tab)。" +msgstr "用 4 個空格縮排,不要用 tab 鍵。" #: ../../tutorial/controlflow.rst:904 msgid "" @@ -1057,8 +1055,8 @@ msgid "" "nesting depth) and large indentation (easier to read). Tabs introduce " "confusion, and are best left out." msgstr "" -"4 個空格是小縮排(容許更大的巢套深度)和大縮排(較易閱讀)之間的折衷方案。欄" -"標會造成混亂,最好別用。" +"4 個空格是小縮排(容許更大的巢套深度)和大縮排(較易閱讀)之間的折衷方案。" +"Tab 鍵會造成混亂,最好別用。" #: ../../tutorial/controlflow.rst:908 msgid "Wrap lines so that they don't exceed 79 characters." @@ -1080,7 +1078,7 @@ msgstr "用空行分隔函式和 class(類別),及函式內較大塊的程 #: ../../tutorial/controlflow.rst:916 msgid "When possible, put comments on a line of their own." -msgstr "如果可以,把說明放在單獨一行。" +msgstr "如果可以,把註解放在單獨一行。" #: ../../tutorial/controlflow.rst:918 msgid "Use docstrings." @@ -1103,7 +1101,7 @@ msgid "" msgstr "" "Class 和函式的命名樣式要一致;按慣例,命名 class 用 ``UpperCamelCase``\\ (駝" "峰式大小寫),命名函式與 method 用 ``lowercase_with_underscores``\\ (小寫加" -"底線)。永遠用 ``self`` 作為第一個 method 引數的名稱(關於 class 和 method," +"底線)。永遠用 ``self`` 作為 method 第一個引數的名稱(關於 class 和 method," "詳見 :ref:`tut-firstclasses`\\ )。" #: ../../tutorial/controlflow.rst:928 @@ -1121,8 +1119,8 @@ msgid "" "slightest chance people speaking a different language will read or maintain " "the code." msgstr "" -"同樣地,若不同語言使用者閱讀或維護程式碼的可能性微乎其微,就不要在識別碼 " -"(identifier) 中使用非 ASCII 字元。" +"同樣地,若不同語言使用者閱讀或維護程式碼的可能性微乎其微,就不要在命名時使用" +"非 ASCII 字元。" #: ../../tutorial/controlflow.rst:938 msgid "Footnotes" @@ -1134,9 +1132,9 @@ msgid "" "a mutable object is passed, the caller will see any changes the callee makes " "to it (items inserted into a list)." msgstr "" -"實際上,\\ *傳物件參照呼叫 (call by object reference)* 的說法可能較為貼切。因" -"為,若傳遞的是一個可變物件時,呼叫者將看得見被呼叫物件做出的任何改變(例如被" -"插入 list 內的新項目)。" +"實際上,\\ *傳址呼叫 (call by object reference)* 的說法可能較為貼切。因為,若" +"傳遞的是一個可變物件時,呼叫者將看得見被呼叫者對物件做出的任何改變(例如被插" +"入 list 內的新項目)。" #~ msgid "" #~ "If you need to modify the sequence you are iterating over while inside "