diff --git a/CLAUDE.md b/CLAUDE.md index 94332f64b1..891f50c5a7 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -34,6 +34,13 @@ make progress # Check translation progress ### reST Syntax - Preserve `:mod:`, `:func:`, `:class:`, `:term:`, `:ref:`, `:pep:` roles - Use `\\ ` as zero-width separator when Chinese precedes reST syntax +- `\\ ` is also required when a role/literal/emphasis close is immediately followed by an + **opening** full-width punctuation mark (`(`, `「`, `『`) — confirmed by corpus-wide grep: + ~1 unescaped vs ~473 escaped occurrences. Example: `` :class:`Widget`\\ ( ``. +- `\\ ` is **not** needed before **closing/medial** full-width punctuation (`。`, `,`, `:`, + `;`, `!`, `?`, `」`, `』`, `)`) — this is the dominant, unescaped, CI-passing convention + throughout the corpus (thousands of unescaped examples vs. a handful of escaped outliers). + Do not add `\\ ` there even if it looks visually similar to the open-paren case. ## Key Resources diff --git a/builtins/constants.po b/builtins/constants.po index bb6a950abc..2d5d5d402f 100644 --- a/builtins/constants.po +++ b/builtins/constants.po @@ -19,23 +19,27 @@ msgstr "" #: ../../builtins/constants.rst:4 msgid "Built-in Constants" -msgstr "" +msgstr "內建常數" #: ../../builtins/constants.rst:6 msgid "A small number of constants live in the built-in namespace. They are:" -msgstr "" +msgstr "有一小部分的常數存在於內建命名空間中。他們是:" #: ../../builtins/constants.rst:10 msgid "" "The false value of the :class:`bool` type. Assignments to ``False`` are " "illegal and raise a :exc:`SyntaxError`." msgstr "" +"在 :class:`bool` 型別中的 false 值。對於 ``False`` 的賦值是不合法的,並且會拋" +"出 :exc:`SyntaxError`。" #: ../../builtins/constants.rst:16 msgid "" "The true value of the :class:`bool` type. Assignments to ``True`` are " "illegal and raise a :exc:`SyntaxError`." msgstr "" +"在 :class:`bool` 型別中的 true 值。對於 ``True`` 的賦值是不合法的,並且會拋" +"出 :exc:`SyntaxError`。" #: ../../builtins/constants.rst:22 msgid "" @@ -44,6 +48,9 @@ msgid "" "illegal and raise a :exc:`SyntaxError`. ``None`` is the sole instance of " "the :class:`~types.NoneType` type." msgstr "" +"一個經常被使用來表達缺少值的物件,例如未傳送預設的引數至函式時。對於 " +"``None`` 的賦值是不合法的,並且會引發 :exc:`SyntaxError`。``None`` 是 :class:" +"`~types.NoneType` 型別的唯一實例。" #: ../../builtins/constants.rst:30 msgid "" @@ -56,6 +63,12 @@ msgid "" "boolean context. :data:`!NotImplemented` is the sole instance of the :class:" "`types.NotImplementedType` type." msgstr "" +"會被二元特殊方法 (binary special methods)(如::meth:`~object.__eq__`、:meth:" +"`~object.__lt__`、:meth:`~object.__add__`、:meth:`~object.__rsub__` 等)所回" +"傳的特殊值,代表著該運算沒有針對其他型別的實作。同理也可以被原地二元特殊方法 " +"(in-place binary special methods) (如::meth:`~object.__imul__`、:meth:" +"`~object.__iand__` 等)回傳。它不應該被作為 boolean(布林)來解讀。:data:`!" +"NotImplemented` 是 :class:`types.NotImplementedType` 型別的唯一實例。" #: ../../builtins/constants.rst:40 msgid "" @@ -67,10 +80,15 @@ msgid "" "error message or the :data:`!NotImplemented` value being returned to Python " "code." msgstr "" +"當一個二元 (binary) 或原地 (in-place) 方法回傳 :data:`!NotImplemented`,直譯" +"器會嘗試反映該操作到其他型別(或是其他後備 (fallback),取決於是哪種運算子)。" +"如果所有的常識都回傳 :data:`!NotImplemented`,直譯器會拋出適當的例外。不正確" +"的回傳 :data:`!NotImplemented` 會造成誤導的錯誤訊息或是 :data:`!" +"NotImplemented` 值被傳回到 Python 程式碼中。" #: ../../builtins/constants.rst:47 msgid "See :ref:`implementing-the-arithmetic-operations` for examples." -msgstr "" +msgstr "請參見 :ref:`implementing-the-arithmetic-operations` 以找到更多範例。" #: ../../builtins/constants.rst:51 msgid "" @@ -78,10 +96,14 @@ msgid "" "interchangeable. This constant should only be used as described above; see :" "exc:`NotImplementedError` for details on correct usage of the exception." msgstr "" +":data:`!NotImplemented` 與 :exc:`!NotImplementedError` 並不一樣且不可互換。這" +"個常數只能用於上述的情況;欲知更多如何正確使用它們的細節,請參見 :exc:" +"`NotImplementedError`。" #: ../../builtins/constants.rst:56 msgid "Evaluating :data:`!NotImplemented` in a boolean context was deprecated." msgstr "" +"在 boolean(布林)上下文中對 :data:`!NotImplemented` 求值的操作已被棄用。" #: ../../builtins/constants.rst:59 msgid "" @@ -89,6 +111,9 @@ msgid "" "`TypeError`. It previously evaluated to :const:`True` and emitted a :exc:" "`DeprecationWarning` since Python 3.9." msgstr "" +"在 boolean 上下文中解讀 :data:`!NotImplemented` 現在會引發 :exc:`TypeError`。" +"過去自 Python 3.9 以來,這會被解讀成 :const:`True`,並發出 :exc:" +"`DeprecationWarning`" #: ../../builtins/constants.rst:68 msgid "" @@ -97,12 +122,17 @@ msgid "" "but assignment to ``...`` raises a :exc:`SyntaxError`. ``Ellipsis`` is the " "sole instance of the :class:`types.EllipsisType` type." msgstr "" +"與刪節號 \"``...``\" 字面相同,是一個經常被用來表示某些東西被省略的物件。對" +"於 ``Ellipsis`` 的賦值是可能的,但對於 ``...`` 的賦值會引發 :exc:" +"`SyntaxError`。``Ellipsis`` 是 :class:`types.EllipsisType` 型別的唯一實例。" #: ../../builtins/constants.rst:76 msgid "" "This constant is true if Python was not started with an :option:`-O` option. " "See also the :keyword:`assert` statement." msgstr "" +"如果 Python 沒有被以 :option:`-O` 選項啟動,則此常數為 true。請參見 :keyword:" +"`assert` 陳述式。" #: ../../builtins/constants.rst:82 msgid "" @@ -110,10 +140,13 @@ msgid "" "cannot be reassigned (assignments to them, even as an attribute name, raise :" "exc:`SyntaxError`), so they can be considered \"true\" constants." msgstr "" +":data:`None`,:data:`False`,:data:`True`,以及 :data:`__debug__` 都是不能被" +"重新賦值的(任何對它們的賦值,即使是屬性的名稱,也會拋出 :exc:" +"`SyntaxError`)。因此,它們可以被視為”真正的”常數。" #: ../../builtins/constants.rst:90 msgid "Constants added by the :mod:`site` module" -msgstr "" +msgstr "由 :mod:`site` module(模組)所添增的常數" #: ../../builtins/constants.rst:92 msgid "" @@ -122,6 +155,9 @@ msgid "" "constants to the built-in namespace. They are useful for the interactive " "interpreter shell and should not be used in programs." msgstr "" +":mod:`site` module(模組)(在啟動期間自動 import ,除非有給予 :option:`-S` " +"指令行選項)會添增一些常數到內建命名空間 (built-in namespace) 中。它們在互動" +"式直譯器中是很有幫助的,但不應該在程式 (programs) 中被使用。" #: ../../builtins/constants.rst:100 msgid "" @@ -129,6 +165,9 @@ msgid "" "EOF) to exit\", and when accessed directly in the interactive interpreter or " "called as functions, raise :exc:`SystemExit` with the specified exit code." msgstr "" +"當印出物件時,會印出一個訊息:\"Use quit() or Ctrl-D (i.e. EOF) to exit\"。當" +"直接在互動式直譯器中存取或作為函式呼叫時,會引發 :exc:`SystemExit` 並帶有指定" +"的返回碼(exit code)。" #: ../../builtins/constants.rst:108 msgid "" @@ -137,12 +176,15 @@ msgid "" "in the interactive interpreter, invokes the built-in help system (see :func:" "`help`)." msgstr "" +"當印出此物件時,會印出訊息 \"Type help() for interactive help, or " +"help(object) for help about object.\",並在互動式直譯器中直接存取時,會叫用內" +"建的幫助系統(參見 :func:`help`)。" #: ../../builtins/constants.rst:116 msgid "" "Objects that when printed or called, print the text of copyright or credits, " "respectively." -msgstr "" +msgstr "當印出或是呼叫此物件時,分別會印出版權與致謝的文字。" #: ../../builtins/constants.rst:121 msgid "" @@ -150,11 +192,13 @@ msgid "" "full license text\", and when called, displays the full license text in a " "pager-like fashion (one screen at a time)." msgstr "" +"當印出此物件時,會印出訊息 \"Type license() to see the full license text\"," +"並在呼叫時以分頁形式印出完整的許可證文字(一次一整個畫面)。" #: ../../builtins/constants.rst:65 msgid "..." -msgstr "" +msgstr "..." #: ../../builtins/constants.rst:65 msgid "ellipsis literal" -msgstr "" +msgstr "ellipsis literal(刪節號字面值)" diff --git a/builtins/exceptions.po b/builtins/exceptions.po index ee69fc647d..ee289267f3 100644 --- a/builtins/exceptions.po +++ b/builtins/exceptions.po @@ -19,7 +19,7 @@ msgstr "" #: ../../builtins/exceptions.rst:4 msgid "Built-in Exceptions" -msgstr "" +msgstr "內建的例外" #: ../../builtins/exceptions.rst:10 msgid "" @@ -30,6 +30,11 @@ msgid "" "from which *it* is derived). Two exception classes that are not related via " "subclassing are never equivalent, even if they have the same name." msgstr "" +"在 Python 中,所有例外必須是從 :class:`BaseException` 衍生的類別的實例。在陳" +"述式 :keyword:`try` 搭配 :keyword:`except` 子句裡提到一個特定的類別時,那個子" +"句也會處理任何從該類別衍生的例外類別(但不會處理該類別\\ *衍生自*\\ 的例外類" +"別)。兩個不是由子類別關係關聯起來的例外類別永遠不相等,就算它們有相同的名稱" +"也是如此。" #: ../../builtins/exceptions.rst:19 msgid "" @@ -40,6 +45,10 @@ msgid "" "and a string explaining the code). The associated value is usually passed " "as arguments to the exception class's constructor." msgstr "" +"此章節裡列出的內建例外可以從直譯器或內建函式產生。除了特別提到的地方之外,它" +"們會有一個\\ *關聯值*\\ 表示錯誤發生的詳細原因。這可能是一個字串,或者是一些" +"資訊項目組成的元組(例如一個錯誤代碼及一個解釋該代碼的字串)。這個關聯值通常" +"當作引數傳遞給例外類別的建構函式。" #: ../../builtins/exceptions.rst:26 msgid "" @@ -49,6 +58,9 @@ msgid "" "that there is nothing to prevent user code from raising an inappropriate " "error." msgstr "" +"使用者的程式碼可以引發內建例外。這可以用來測試例外處理器或者用來回報一個錯誤" +"條件,*就像*\\ 直譯器會引發相同例外的情況;但需要注意的是沒有任何方式可以避免" +"使用者的程式碼引發不適當的錯誤。" #: ../../builtins/exceptions.rst:31 msgid "" @@ -58,16 +70,19 @@ msgid "" "`BaseException`. More information on defining exceptions is available in " "the Python Tutorial under :ref:`tut-userexceptions`." msgstr "" +"可以從內建的例外類別定義新的例外子類別;程式設計師被鼓勵從 :exc:`Exception` " +"類別或其子類別衍生新的例外,而不是從 :exc:`BaseException` 來衍生。更多關於定" +"義例外的資訊可以在 Python 教學中的\\ :ref:`tut-userexceptions`\\ 裡取得。" #: ../../builtins/exceptions.rst:39 msgid "Exception context" -msgstr "" +msgstr "例外的情境" #: ../../builtins/exceptions.rst:46 msgid "" "Three attributes on exception objects provide information about the context " "in which the exception was raised:" -msgstr "" +msgstr "三個例外物件上的屬性提供關於引發此例外的情境的資訊:" #: ../../builtins/exceptions.rst:53 msgid "" @@ -77,16 +92,21 @@ msgid "" "`except` or :keyword:`finally` clause, or a :keyword:`with` statement, is " "used." msgstr "" +"當引發一個新的例外而同時有另一個例外已經正在被處理時,這個新例外的 :attr:`!" +"__context__` 屬性會自動被設成那個已處理的例外。當使用 :keyword:`except` 或 :" +"keyword:`finally` 子句或 :keyword:`with` 陳述式的時候例外會被處理。" #: ../../builtins/exceptions.rst:59 msgid "" "This implicit exception context can be supplemented with an explicit cause " "by using :keyword:`!from` with :keyword:`raise`::" msgstr "" +"這個隱含的例外情境可以透過使用 :keyword:`!from` 搭配 :keyword:`raise` 來補充" +"明確的原因: ::" #: ../../builtins/exceptions.rst:63 msgid "raise new_exc from original_exc" -msgstr "" +msgstr "raise new_exc from original_exc" #: ../../builtins/exceptions.rst:65 msgid "" @@ -99,6 +119,12 @@ msgid "" "while leaving the old exception available in :attr:`!__context__` for " "introspection when debugging." msgstr "" +"在 :keyword:`from` 後面的運算式必須是一個例外或 ``None``。它將會被設定" +"成所引發例外的 :attr:`!__cause__`。設定 :attr:`!__cause__` 也隱含地設定 :" +"attr:`!__suppress_context__` 屬性為 ``True``,因此使用 ``raise new_exc from " +"None`` 實際上會以新的例外取代舊的例外以利於顯示(例如轉換 :exc:`KeyError` " +"為 :exc:`AttributeError`),同時保持舊的例外可以透過 :attr:`!__context__` 取" +"得以方便 debug 的時候檢查。" #: ../../builtins/exceptions.rst:74 msgid "" @@ -108,6 +134,11 @@ msgid "" "chained exception in :attr:`!__context__` is shown only if :attr:`!" "__cause__` is :const:`None` and :attr:`!__suppress_context__` is false." msgstr "" +"預設的回溯 (traceback) 顯示程式碼會顯示這些連鎖的例外 (chained exception) 加" +"上例外本身的回溯。當存在的時候,在 :attr:`!__cause__` 中明確地連鎖的例外總是" +"會被顯示。而在 :attr:`!__context__` 中隱含地連鎖的例外只有當 :attr:`!" +"__cause__` 是 :const:`None` 且 :attr:`!__suppress_context__` 是 false 時才會" +"顯示。" #: ../../builtins/exceptions.rst:80 msgid "" @@ -115,10 +146,12 @@ msgid "" "exceptions so that the final line of the traceback always shows the last " "exception that was raised." msgstr "" +"在任一種情況下,例外本身總是會顯示在任何連鎖例外的後面,因此回溯的最後一列總" +"是顯示最後一個被引發的例外。" #: ../../builtins/exceptions.rst:86 msgid "Inheriting from built-in exceptions" -msgstr "" +msgstr "繼承自內建的例外" #: ../../builtins/exceptions.rst:88 msgid "" @@ -127,6 +160,9 @@ msgid "" "possible conflicts between how the bases handle the ``args`` attribute, as " "well as due to possible memory layout incompatibilities." msgstr "" +"使用者的程式碼可以建立繼承自例外型別的子類別。建議一次只繼承一種例外型別以避" +"免在基底類別之間如何處理 ``args`` 屬性的任何可能衝突,以及可能的記憶體佈局 " +"(memory layout) 不相容。" #: ../../builtins/exceptions.rst:95 msgid "" @@ -137,16 +173,20 @@ msgid "" "between Python versions, leading to new conflicts in the future. Therefore, " "it's recommended to avoid subclassing multiple exception types altogether." msgstr "" +"為了效率,大部分的內建例外使用 C 來實作,參考 :source:`Objects/exceptions." +"c`。一些例外有客製化的記憶體佈局,使其不可能建立一個繼承多種例外型別的子類" +"別。型別的記憶體佈局是實作細節且可能會在不同 Python 版本間改變,造成未來新的" +"衝突。因此,總之建議避免繼承多種例外型別。" #: ../../builtins/exceptions.rst:105 msgid "Base classes" -msgstr "" +msgstr "基底類別 (base classes)" #: ../../builtins/exceptions.rst:107 msgid "" "The following exceptions are used mostly as base classes for other " "exceptions." -msgstr "" +msgstr "以下的例外大部分被用在當作其他例外的基底類別。" #: ../../builtins/exceptions.rst:111 msgid "" @@ -156,6 +196,9 @@ msgid "" "argument(s) to the instance are returned, or the empty string when there " "were no arguments." msgstr "" +"所有內建例外的基底類別。這不是為了讓使用者定義的類別直接繼承(可以使用 :exc:" +"`Exception`)。如果在這個類別的實例上呼叫 :func:`str`,會回傳實例的引數的表" +"示,或者沒有引數的時候會回傳空字串。" #: ../../builtins/exceptions.rst:119 msgid "" @@ -164,6 +207,9 @@ msgid "" "assign a special meaning to the elements of this tuple, while others are " "usually called only with a single string giving an error message." msgstr "" +"提供給該例外建構函式的引數元組。一些內建的例外(像是 :exc:`OSError`)預期接受" +"特定數量的引數並賦予該元組的每一個元素一個特別的意義,其他例外則通常用一個提" +"供錯誤訊息的單一字串來呼叫。" #: ../../builtins/exceptions.rst:126 msgid "" @@ -176,6 +222,11 @@ msgid "" "happened to the traceback of the original ``SomeException`` had we allowed " "it to propagate to the caller. ::" msgstr "" +"此方法設定 *tb* 為該例外的新的回溯並回傳該例外物件。在 :pep:`3134` 的例外連鎖" +"功能變得可用之前,此方法曾被更普遍使用。下面的範例顯示我們如何將 " +"``SomeException`` 的實例轉換為 ``OtherException`` 的實例同時保留回溯。一旦被" +"引發,目前的 frame 會被加進 ``OtherException`` 的回溯,就像原來 " +"``SomeException`` 的回溯會發生的一樣,我們允許它被傳遞給呼叫者: ::" #: ../../builtins/exceptions.rst:135 msgid "" @@ -185,12 +236,19 @@ msgid "" " tb = sys.exception().__traceback__\n" " raise OtherException(...).with_traceback(tb)" msgstr "" +"try:\n" +" ...\n" +"except SomeException:\n" +" tb = sys.exception().__traceback__\n" +" raise OtherException(...).with_traceback(tb)" #: ../../builtins/exceptions.rst:143 msgid "" "A writable field that holds the :ref:`traceback object ` " "associated with this exception. See also: :ref:`raise`." msgstr "" +"可寫入的欄位,儲存關聯到該例外的\\ :ref:`回溯物件 `。也可" +"以參考 :ref:`raise`。" #: ../../builtins/exceptions.rst:149 msgid "" @@ -198,18 +256,24 @@ msgid "" "standard traceback after the exception string. A :exc:`TypeError` is raised " "if ``note`` is not a string." msgstr "" +"新增字串 ``note`` 到例外的備註,在標準的回溯裡,備註出現在例外字串的後面。如" +"果 ``note`` 不是字串則引發 :exc:`TypeError`。" #: ../../builtins/exceptions.rst:157 msgid "" "A list of the notes of this exception, which were added with :meth:" "`add_note`. This attribute is created when :meth:`add_note` is called." msgstr "" +"該例外的備註串列,使用 :meth:`add_note` 來新增。此屬性在 :meth:`add_note` 被" +"呼叫的時候建立。" #: ../../builtins/exceptions.rst:165 msgid "" "All built-in, non-system-exiting exceptions are derived from this class. " "All user-defined exceptions should also be derived from this class." msgstr "" +"所有內建、非系統退出 (non-system-exiting) 的例外都衍生自此類別。所有使用者定" +"義的例外應該也要衍生自此類別。" #: ../../builtins/exceptions.rst:171 msgid "" @@ -217,12 +281,16 @@ msgid "" "arithmetic errors: :exc:`OverflowError`, :exc:`ZeroDivisionError`, :exc:" "`FloatingPointError`." msgstr "" +"各種運算錯誤所引發的那些內建例外::exc:`OverflowError`、:exc:" +"`ZeroDivisionError`、:exc:`FloatingPointError` 的基底類別。" #: ../../builtins/exceptions.rst:178 msgid "" "Raised when a :ref:`buffer ` related operation cannot be " "performed." msgstr "" +"當\\ :ref:`緩衝 (buffer) ` 相關的操作無法被執行時會引發此例" +"外。" #: ../../builtins/exceptions.rst:184 msgid "" @@ -230,18 +298,20 @@ msgid "" "on a mapping or sequence is invalid: :exc:`IndexError`, :exc:`KeyError`. " "This can be raised directly by :func:`codecs.lookup`." msgstr "" +"當使用在對映或序列上的鍵或索引是無效的時候所引發的例外::exc:`IndexError`、:" +"exc:`KeyError` 的基底類別。這可以被 :func:`codecs.lookup` 直接引發。" #: ../../builtins/exceptions.rst:190 msgid "Concrete exceptions" -msgstr "" +msgstr "實體例外" #: ../../builtins/exceptions.rst:192 msgid "The following exceptions are the exceptions that are usually raised." -msgstr "" +msgstr "以下的例外是通常會被引發的例外。" #: ../../builtins/exceptions.rst:198 msgid "Raised when an :keyword:`assert` statement fails." -msgstr "" +msgstr "當 :keyword:`assert` 陳述式失敗的時候被引發。" #: ../../builtins/exceptions.rst:203 msgid "" @@ -249,24 +319,26 @@ msgid "" "assignment fails. (When an object does not support attribute references or " "attribute assignments at all, :exc:`TypeError` is raised.)" msgstr "" +"當屬性參照(參考 :ref:`attribute-references`)或賦值失敗的時候被引發。(當物" +"件根本不支援屬性參照或屬性賦值的時候,:exc:`TypeError` 會被引發。)" #: ../../builtins/exceptions.rst:207 msgid "" "The optional *name* and *obj* keyword-only arguments set the corresponding " "attributes:" -msgstr "" +msgstr "可選的僅限關鍵字引數 *name* 和 *obj* 會設定對應的屬性:" #: ../../builtins/exceptions.rst:212 msgid "The name of the attribute that was attempted to be accessed." -msgstr "" +msgstr "嘗試被存取的屬性名稱。" #: ../../builtins/exceptions.rst:216 msgid "The object that was accessed for the named attribute." -msgstr "" +msgstr "存取指定屬性的物件。" #: ../../builtins/exceptions.rst:218 msgid "Added the :attr:`name` and :attr:`obj` attributes." -msgstr "" +msgstr "新增 :attr:`name` 與 :attr:`obj` 屬性。" #: ../../builtins/exceptions.rst:223 msgid "" @@ -274,10 +346,13 @@ msgid "" "without reading any data. (Note: the :meth:`io.TextIOBase.read` and :meth:" "`io.IOBase.readline` methods return an empty string when they hit EOF.)" msgstr "" +"當 :func:`input` 函式在沒有讀到任何資料而到達檔案結尾 (end-of-file, EOF) 條件" +"的時候被引發。(注意::meth:`io.TextIOBase.read` 和 :meth:`io.IOBase." +"readline` 方法當達到 EOF 時會回傳空字串。)" #: ../../builtins/exceptions.rst:230 msgid "Not currently used." -msgstr "" +msgstr "目前沒有被使用。" #: ../../builtins/exceptions.rst:235 msgid "" @@ -286,6 +361,9 @@ msgid "" "exc:`BaseException` instead of :exc:`Exception` since it is technically not " "an error." msgstr "" +"當 :term:`generator` 或 :term:`coroutine` 被關閉的時候被引發;參考 :meth:" +"`generator.close` 和 :meth:`coroutine.close`。此例外直接繼承自 :exc:" +"`BaseException` 而不是 :exc:`Exception`,因為技術上來說這不是一個錯誤。" #: ../../builtins/exceptions.rst:243 msgid "" @@ -293,24 +371,26 @@ msgid "" "module. Also raised when the \"from list\" in ``from ... import`` has a " "name that cannot be found." msgstr "" +"當 :keyword:`import` 陳述式嘗試載入模組遇到問題的時候會被引發。當 ``from ... " +"import`` 裡的 \"from list\" 包含找不到的名稱時也會被引發。" #: ../../builtins/exceptions.rst:247 msgid "" "The optional *name* and *path* keyword-only arguments set the corresponding " "attributes:" -msgstr "" +msgstr "可選的僅限關鍵字引數 *name* 和 *path* 設定對應的屬性:" #: ../../builtins/exceptions.rst:252 msgid "The name of the module that was attempted to be imported." -msgstr "" +msgstr "嘗試引入 (import) 的模組名稱。" #: ../../builtins/exceptions.rst:256 msgid "The path to any file which triggered the exception." -msgstr "" +msgstr "觸發此例外的任何檔案的路徑。" #: ../../builtins/exceptions.rst:258 msgid "Added the :attr:`name` and :attr:`path` attributes." -msgstr "" +msgstr "新增 :attr:`name` 與 :attr:`path` 屬性。" #: ../../builtins/exceptions.rst:263 msgid "" @@ -318,6 +398,8 @@ msgid "" "module could not be located. It is also raised when ``None`` is found in :" "data:`sys.modules`." msgstr "" +":exc:`ImportError` 的子類別,當模組不能被定位的時候會被 :keyword:`import` 所" +"引發。當在 :data:`sys.modules` 裡找到 ``None`` 時也會被引發。" #: ../../builtins/exceptions.rst:272 msgid "" @@ -325,12 +407,14 @@ msgid "" "silently truncated to fall in the allowed range; if an index is not an " "integer, :exc:`TypeError` is raised.)" msgstr "" +"當序列的索引超出範圍的時候會被引發。(切片索引 (slice indices) 會默默地被截短" +"使其能落在允許的範圍內;如果索引不是整數,:exc:`TypeError` 會被引發。)" #: ../../builtins/exceptions.rst:281 msgid "" "Raised when a mapping (dictionary) key is not found in the set of existing " "keys." -msgstr "" +msgstr "當對映(字典)的鍵無法在已存在的鍵的集合中被找到時會被引發。" #: ../../builtins/exceptions.rst:288 msgid "" @@ -340,6 +424,10 @@ msgid "" "accidentally caught by code that catches :exc:`Exception` and thus prevent " "the interpreter from exiting." msgstr "" +"當使用者輸入中斷鍵 (interrupt key)(一般來說是 :kbd:`Control-C` 或 :kbd:" +"`Delete`)時會被引發。在執行過程中,會定期檢查是否產生中斷。此例外繼承自 :" +"exc:`BaseException` 以防止意外地被捕捉 :exc:`Exception` 的程式碼所捕捉,而因" +"此讓直譯器無法結束。" #: ../../builtins/exceptions.rst:296 msgid "" @@ -349,6 +437,10 @@ msgid "" "allow :exc:`KeyboardInterrupt` to end the program as quickly as possible or " "avoid raising it entirely. (See :ref:`handlers-and-exceptions`.)" msgstr "" +"捕捉 :exc:`KeyboardInterrupt` 需要特殊的考量。因為它可以在無法預期的時間點被" +"引發,可能在某些情況下讓正在跑的程式處在一個不一致的狀態。一般來說最好讓 :" +"exc:`KeyboardInterrupt` 越快結束程式越好,或者完全避免引發它。(參考 :ref:" +"`handlers-and-exceptions`。)" #: ../../builtins/exceptions.rst:306 msgid "" @@ -360,6 +452,11 @@ msgid "" "recover from this situation; it nevertheless raises an exception so that a " "stack traceback can be printed, in case a run-away program was the cause." msgstr "" +"當一個操作用光了記憶體但情況還可能被修復 (rescued)(透過刪除一些物件)的時候" +"被引發。關聯值是一個字串,表示什麼類型的(內部)操作用光了記憶體。需注意的是" +"因為底層的記憶體管理架構(C 的 :c:func:`malloc` 函式),直譯器可能無法總是完" +"整地從該情況中修復;僅管如此,它還是引發例外以讓堆疊回溯可以被印出,以防原因" +"出在失控的程式。" #: ../../builtins/exceptions.rst:317 msgid "" @@ -367,18 +464,20 @@ msgid "" "unqualified names. The associated value is an error message that includes " "the name that could not be found." msgstr "" +"當找不到本地或全域的名稱時會被引發。這只應用在不合格的名稱 (unqualified " +"name) 上。關聯值是一個錯誤訊息,包含那個無法被找到的名稱。" #: ../../builtins/exceptions.rst:321 msgid "The optional *name* keyword-only argument sets the attribute:" -msgstr "" +msgstr "可選的僅限關鍵字引數 *name* 設定對應的屬性:" #: ../../builtins/exceptions.rst:325 msgid "The name of the variable that was attempted to be accessed." -msgstr "" +msgstr "嘗試被存取的變數名稱。" #: ../../builtins/exceptions.rst:327 msgid "Added the :attr:`name` attribute." -msgstr "" +msgstr "新增 :attr:`name` 屬性。" #: ../../builtins/exceptions.rst:333 msgid "" @@ -387,6 +486,9 @@ msgid "" "derived classes to override the method, or while the class is being " "developed to indicate that the real implementation still needs to be added." msgstr "" +"此例外衍生自 :exc:`RuntimeError`。在使用者定義的基礎類別裡,當抽象方法要求衍" +"生類別覆寫該方法時應該要引發此例外,或者當類別正在開發中,可用此例外表示還需" +"要加入真正的實作。" #: ../../builtins/exceptions.rst:340 msgid "" @@ -394,6 +496,8 @@ msgid "" "be supported at all -- in that case either leave the operator / method " "undefined or, if a subclass, set it to :data:`None`." msgstr "" +"此例外不應該用來表示根本沒有要支援的運算子或方法 ── 在這個情況下可以讓該運算" +"子或方法保持未定義,或者如果是子類別的話將其設成 :data:`None`。" #: ../../builtins/exceptions.rst:346 msgid "" @@ -401,6 +505,9 @@ msgid "" "interchangeable. This exception should only be used as described above; see :" "data:`NotImplemented` for details on correct usage of the built-in constant." msgstr "" +":exc:`!NotImplementedError` 和 :data:`!NotImplemented` 並不是可互換的。這個例" +"外只能用在上面描述的情況;參考 :data:`NotImplemented` 裡關於內建常數正確使用" +"方法的細節。" #: ../../builtins/exceptions.rst:357 msgid "" @@ -408,6 +515,8 @@ msgid "" "error, including I/O failures such as \"file not found\" or \"disk " "full\" (not for illegal argument types or other incidental errors)." msgstr "" +"當系統函式回傳系統相關錯誤,包含像\"找不到檔案\"或\"硬碟已滿\"的 I/O 失敗會引" +"發此例外(而非不合法的引數或其他次要的錯誤)。" #: ../../builtins/exceptions.rst:361 msgid "" @@ -417,6 +526,9 @@ msgid "" "`~BaseException.args` attribute contains only a 2-tuple of the first two " "constructor arguments." msgstr "" +"建構函式的第二種形式會設定以下描述的相對應屬性。如果沒有給定則屬性預設為 :" +"const:`None`。為了向後相容,如果傳入三個引數,:attr:`~BaseException.args` 屬" +"性只會是包含建構函式前兩個引數的雙元素元組。" #: ../../builtins/exceptions.rst:367 msgid "" @@ -426,10 +538,14 @@ msgid "" "exc:`OSError` directly or via an alias, and is not inherited when " "subclassing." msgstr "" +"如同下面的\\ `作業系統例外 `_\\ 所描述,實際上建構函式通常回" +"傳 :exc:`OSError` 的子類別。會依據最後 :attr:`.errno` 的值決定特定子類別。這" +"個行為只發生在直接建構 :exc:`OSError` 或透過別名,且產生子類別的時候不會被繼" +"承。" #: ../../builtins/exceptions.rst:375 msgid "A numeric error code from the C variable :c:data:`errno`." -msgstr "" +msgstr "從 C 變數 :c:data:`errno` 而來的數值錯誤代碼。" #: ../../builtins/exceptions.rst:379 msgid "" @@ -437,6 +553,8 @@ msgid "" "errno` attribute is then an approximate translation, in POSIX terms, of that " "native error code." msgstr "" +"在 Windows 下,這會提供你原生的 Windows 錯誤代碼。而 :attr:`.errno` 屬性是一" +"個該原生錯誤代碼對於 POSIX 來說的近似翻譯。" #: ../../builtins/exceptions.rst:383 msgid "" @@ -445,6 +563,9 @@ msgid "" "*errno* argument is ignored. On other platforms, the *winerror* argument is " "ignored, and the :attr:`winerror` attribute does not exist." msgstr "" +"在 Windows 下,如果建構函式引數 *winerror* 是整數,則 :attr:`.errno` 屬性會根" +"據該 Windows 錯誤代碼來決定,且 *errno* 引數會被忽略。在其他平台上," +"*winerror* 引數會被忽略,而 :attr:`winerror` 屬性會不存在。" #: ../../builtins/exceptions.rst:391 msgid "" @@ -452,6 +573,8 @@ msgid "" "formatted by the C functions :c:func:`!perror` under POSIX, and :c:func:`!" "FormatMessage` under Windows." msgstr "" +"作業系統提供的對應錯誤訊息。在 POSIX 下會使用 C 函式 :c:func:`!perror` 做格式" +"化,而在 Windows 下會使用 :c:func:`!FormatMessage`。" #: ../../builtins/exceptions.rst:399 msgid "" @@ -461,6 +584,9 @@ msgid "" "rename`), :attr:`filename2` corresponds to the second file name passed to " "the function." msgstr "" +"對於包含檔案系統路徑的例外(像是 :func:`open` 或 :func:`os.unlink`),:attr:" +"`filename` 是傳入函式的檔案名稱。對於包含兩個檔案系統路徑的函式(像是 :func:" +"`os.rename`),:attr:`filename2` 對應到傳入函式的第二個檔案名稱。" #: ../../builtins/exceptions.rst:406 msgid "" @@ -468,6 +594,9 @@ msgid "" "error`, :exc:`select.error` and :exc:`!mmap.error` have been merged into :" "exc:`OSError`, and the constructor may return a subclass." msgstr "" +":exc:`EnvironmentError`、:exc:`IOError`、:exc:`WindowsError`、:exc:`socket." +"error`、:exc:`select.error` 及 :exc:`!mmap.error` 已合併進 :exc:`OSError`,而" +"建構函式可能會回傳子類別。" #: ../../builtins/exceptions.rst:412 msgid "" @@ -476,6 +605,9 @@ msgid "" "`filesystem encoding and error handler`. Also, the *filename2* constructor " "argument and attribute was added." msgstr "" +":attr:`filename` 屬性現在是傳入函式的原始檔名,而不是從\\ :term:`檔案系統編碼" +"和錯誤處理函式 `\\ 編碼或解碼過的名" +"稱。並且新增 *filename2* 建構函式引數與屬性。" #: ../../builtins/exceptions.rst:421 msgid "" @@ -486,6 +618,10 @@ msgid "" "Because of the lack of standardization of floating-point exception handling " "in C, most floating-point operations are not checked." msgstr "" +"當運算操作的結果太大而無法表示的時候會引發此例外。這不會發生在整數上(會改成" +"引發 :exc:`MemoryError` 而不是放棄)。然而,因為一些歷史因素,OverflowError " +"有時候會因為整數在要求範圍之外而引發。因為在 C 裡面缺乏浮點數例外處理的標準" +"化,大部分的浮點數運算都沒有被檢查。" #: ../../builtins/exceptions.rst:431 msgid "" @@ -493,36 +629,41 @@ msgid "" "operation is blocked during interpreter shutdown also known as :term:`Python " "finalization `." msgstr "" +"此例外衍生自 :exc:`RuntimeError`。當一個操作在直譯器關閉(也稱作 :term:" +"`Python 最終化 (Python finalization) `)期間被阻塞會引" +"發此例外。" #: ../../builtins/exceptions.rst:435 msgid "" "Examples of operations which can be blocked with a :exc:" "`PythonFinalizationError` during the Python finalization:" msgstr "" +"在 Python 最終化期間,能夠以 :exc:`PythonFinalizationError` 被阻塞的操作範" +"例:" #: ../../builtins/exceptions.rst:438 msgid "Creating a new Python thread." -msgstr "" +msgstr "建立新的 Python 執行緒。" #: ../../builtins/exceptions.rst:439 msgid ":meth:`Joining ` a running daemon thread." -msgstr "" +msgstr ":meth:`Join ` 一個執行中的常駐執行緒。" #: ../../builtins/exceptions.rst:440 msgid ":func:`os.fork`." -msgstr "" +msgstr ":func:`os.fork`。" #: ../../builtins/exceptions.rst:442 msgid "See also the :func:`sys.is_finalizing` function." -msgstr "" +msgstr "也可以參閱 :func:`sys.is_finalizing` 函式。" #: ../../builtins/exceptions.rst:444 ../../builtins/exceptions.rst:457 msgid "Previously, a plain :exc:`RuntimeError` was raised." -msgstr "" +msgstr "在之前,會引發一般的 :exc:`RuntimeError`。" #: ../../builtins/exceptions.rst:449 msgid ":meth:`threading.Thread.join` can now raise this exception." -msgstr "" +msgstr ":meth:`threading.Thread.join` 現在可以引發此例外。" #: ../../builtins/exceptions.rst:453 msgid "" @@ -530,6 +671,8 @@ msgid "" "interpreter detects that the maximum recursion depth (see :func:`sys." "getrecursionlimit`) is exceeded." msgstr "" +"此例外衍生自 :exc:`RuntimeError`。當直譯器偵測到超過最大的遞迴深度(參考 :" +"func:`sys.getrecursionlimit`)時會引發此例外。" #: ../../builtins/exceptions.rst:463 msgid "" @@ -538,6 +681,9 @@ msgid "" "after it has been garbage collected. For more information on weak " "references, see the :mod:`weakref` module." msgstr "" +"當一個被 :func:`weakref.proxy` 函式建立的弱參照代理 (weak reference proxy) 被" +"用來存取已經被垃圾回收 (garbage collected) 的參照物屬性時會引發此例外。更多關" +"於弱參照的資訊參考 :mod:`weakref` 模組。" #: ../../builtins/exceptions.rst:471 msgid "" @@ -545,6 +691,8 @@ msgid "" "categories. The associated value is a string indicating what precisely went " "wrong." msgstr "" +"當偵測到一個不屬於任何其他種類的錯誤時會引發此例外。關聯值是一個表示確切什麼" +"地方出錯的字串。" #: ../../builtins/exceptions.rst:478 msgid "" @@ -552,6 +700,8 @@ msgid "" "`~iterator.__next__` method to signal that there are no further items " "produced by the iterator." msgstr "" +"會被內建函式 :func:`next` 及 :term:`iterator` 的 :meth:`~iterator.__next__` " +"方法引發,用來表示疊代器沒有更多項目可以產生。" #: ../../builtins/exceptions.rst:484 msgid "" @@ -559,6 +709,8 @@ msgid "" "as an argument when constructing the exception, and defaults to :const:" "`None`." msgstr "" +"此例外物件有單一屬性 :attr:`!value`,當建構此例外時會以引數給定,預設為 :" +"const:`None`。" #: ../../builtins/exceptions.rst:488 msgid "" @@ -566,6 +718,9 @@ msgid "" "`StopIteration` instance is raised, and the value returned by the function " "is used as the :attr:`value` parameter to the constructor of the exception." msgstr "" +"當 :term:`generator` 或 :term:`coroutine` 函式回傳時,新的 :exc:" +"`StopIteration` 實例會被引發,而該函式的回傳值會被用來當作此例外建構函式的 :" +"attr:`value` 參數。" #: ../../builtins/exceptions.rst:493 msgid "" @@ -573,30 +728,38 @@ msgid "" "is converted into a :exc:`RuntimeError` (retaining the :exc:`StopIteration` " "as the new exception's cause)." msgstr "" +"如果產生器程式直接或間接引發 :exc:`StopIteration`,則其會被轉換成 :exc:" +"`RuntimeError`\\ (保留 :exc:`StopIteration` 作為新例外的成因)。" #: ../../builtins/exceptions.rst:497 msgid "" "Added ``value`` attribute and the ability for generator functions to use it " "to return a value." -msgstr "" +msgstr "新增 ``value`` 屬性且產生器函式可以用它來回傳值。" #: ../../builtins/exceptions.rst:501 msgid "" "Introduced the RuntimeError transformation via ``from __future__ import " "generator_stop``, see :pep:`479`." msgstr "" +"透過 ``from __future__ import generator_stop`` 引入 RuntimeError 的轉換,參" +"考 :pep:`479`。" #: ../../builtins/exceptions.rst:505 msgid "" "Enable :pep:`479` for all code by default: a :exc:`StopIteration` error " "raised in a generator is transformed into a :exc:`RuntimeError`." msgstr "" +"預設對所有程式啟用 :pep:`479`:在產生器引發的 :exc:`StopIteration` 錯誤會轉換" +"成 :exc:`RuntimeError`。" #: ../../builtins/exceptions.rst:511 msgid "" "Must be raised by :meth:`~object.__anext__` method of an :term:`asynchronous " "iterator` object to stop the iteration." msgstr "" +"此例外必須被 :term:`asynchronous iterator` 物件的 :meth:`~object.__anext__` " +"方法引發來停止疊代。" #: ../../builtins/exceptions.rst:518 msgid "" @@ -605,44 +768,56 @@ msgid "" "`compile`, :func:`exec`, or :func:`eval`, or when reading the initial script " "or standard input (also interactively)." msgstr "" +"當剖析器遇到語法錯誤時會引發此例外。這可能發生在 :keyword:`import` 陳述式、在" +"呼叫內建函式 :func:`compile`、:func:`exec` 或 :func:`eval` 的時候,或者在讀取" +"初始腳本或標準輸入(也包含互動式)的時候。" #: ../../builtins/exceptions.rst:524 msgid "" "The :func:`str` of the exception instance returns only the error message. " "Details is a tuple whose members are also available as separate attributes." msgstr "" +"例外實例的 :func:`str` 只回傳錯誤訊息。Details 是個元組,其成員也能夠以分開的" +"屬性取得。" #: ../../builtins/exceptions.rst:529 msgid "The name of the file the syntax error occurred in." -msgstr "" +msgstr "發生語法錯誤所在的檔案名稱。" #: ../../builtins/exceptions.rst:533 msgid "" "Which line number in the file the error occurred in. This is 1-indexed: the " "first line in the file has a ``lineno`` of 1." msgstr "" +"發生錯誤所在檔案的列號。這是以 1 開始的索引:檔案第一列的 ``lineno`` 是 1。" #: ../../builtins/exceptions.rst:538 msgid "" "The column in the line where the error occurred. This is 1-indexed: the " "first character in the line has an ``offset`` of 1." msgstr "" +"發生錯誤所在該列的欄號 (column)。這是以 1 開始的索引:該列第一個字元的 " +"``offset`` 是 1。" #: ../../builtins/exceptions.rst:543 msgid "The source code text involved in the error." -msgstr "" +msgstr "涉及該錯誤的原始程式碼文字。" #: ../../builtins/exceptions.rst:547 msgid "" "Which line number in the file the error occurred ends in. This is 1-indexed: " "the first line in the file has a ``lineno`` of 1." msgstr "" +"發生錯誤所在檔案的結束列號。這是以 1 開始的索引:檔案第一列的 ``lineno`` 是 " +"1。" #: ../../builtins/exceptions.rst:552 msgid "" "The column in the end line where the error occurred finishes. This is 1-" "indexed: the first character in the line has an ``offset`` of 1." msgstr "" +"發生錯誤所在該結束列的欄號。這是以 1 開始的索引:該列第一個字元的 ``offset`` " +"是 1。" #: ../../builtins/exceptions.rst:555 msgid "" @@ -651,22 +826,28 @@ msgid "" "expression. For example, compiling f'Bad {a b} field' results in this args " "attribute: ('f-string: ...', ('', 1, 2, '(a b)\\n', 1, 5))." msgstr "" +"對於發生在 f-string 欄位的錯誤,訊息會以 \"f-string: \" 為前綴,而偏移量 " +"(offset) 是從替代運算式建構的文字的偏移量。例如編譯 f'Bad {a b} field' 會得到" +"這個 args 屬性:('f-string: ...', ('', 1, 2, '(a b)\\n', 1, 5))。" #: ../../builtins/exceptions.rst:560 msgid "Added the :attr:`end_lineno` and :attr:`end_offset` attributes." -msgstr "" +msgstr "新增 :attr:`end_lineno` 與 :attr:`end_offset` 屬性。" #: ../../builtins/exceptions.rst:565 msgid "" "Base class for syntax errors related to incorrect indentation. This is a " "subclass of :exc:`SyntaxError`." msgstr "" +"與不正確的縮排有關的語法錯誤的基礎類別。這是 :exc:`SyntaxError` 的子類別。" #: ../../builtins/exceptions.rst:571 msgid "" "Raised when indentation contains an inconsistent use of tabs and spaces. " "This is a subclass of :exc:`IndentationError`." msgstr "" +"當縮排包含製表符號 (tab) 和空白的不一致用法時會引發此例外。這是 :exc:" +"`IndentationError` 的子類別。" #: ../../builtins/exceptions.rst:577 msgid "" @@ -676,6 +857,10 @@ msgid "" "`CPython`, this could be raised by incorrectly using Python's C API, such as " "returning a ``NULL`` value without an exception set." msgstr "" +"當直譯器找到一個內部錯誤,但該情況看起來沒有嚴重到要讓它放棄所有的希望時會引" +"發此例外。關聯值是一個表示什麼地方出錯的字串(以低階的方式表達)。在 :term:" +"`CPython` 中,這可能是因為錯誤地使用 Python 的 C API,例如回傳一個 ``NULL`` " +"值而沒有設定例外。" #: ../../builtins/exceptions.rst:583 msgid "" @@ -687,6 +872,10 @@ msgid "" "associated value) and if possible the source of the program that triggered " "the error." msgstr "" +"如果你確定這個例外不是你的或者所用套件的錯,你應該向你的 Python 直譯器作者或" +"維護者回報此錯誤。務必要回報該 Python 直譯器的版本(``sys.version``;這也會在" +"互動式 Python 會話的開頭被印出)、確切的錯誤訊息(該例外的關聯值)及如果可能" +"的話,觸發此錯誤的程式來源。" #: ../../builtins/exceptions.rst:594 msgid "" @@ -701,6 +890,13 @@ msgid "" "is zero; if it has another type (such as a string), the object's value is " "printed and the exit status is one." msgstr "" +"此例外會被 :func:`sys.exit` 函式引發。它繼承自 :exc:`BaseException` 而不是 :" +"exc:`Exception` 因此不會被捕捉 :exc:`Exception` 的程式意外地捕捉。這允許例外" +"可以正確地向上傳遞並導致直譯器結束。當它未被處理時,Python 直譯器會結束;不會" +"印出堆疊回溯。建構函式接受跟傳入 :func:`sys.exit` 一樣的可選引數。如果該值是" +"整數,它會指定系統的結束狀態(傳入 C 的 :c:func:`!exit` 函式);如果它是 " +"``None``,結束狀態會是 0;如果它是其他型別(例如字串),則物件的值會被印出而" +"結束狀態是 1。" #: ../../builtins/exceptions.rst:605 msgid "" @@ -711,12 +907,16 @@ msgid "" "absolutely positively necessary to exit immediately (for example, in the " "child process after a call to :func:`os.fork`)." msgstr "" +"對 :func:`sys.exit` 的呼叫會轉譯成例外讓負責清理的處理函式(:keyword:`try` 陳" +"述式的 :keyword:`finally` 子句)可以被執行,且讓除錯器可以在不冒著失去控制的" +"風險下執行腳本。如果在絕對有必要立即結束的情況(例如在子行程呼叫完 :func:`os." +"fork` 之後 )可以使用 :func:`os._exit` 函式。" #: ../../builtins/exceptions.rst:614 msgid "" "The exit status or error message that is passed to the constructor. " "(Defaults to ``None``.)" -msgstr "" +msgstr "傳入建構函式的結束狀態或錯誤訊息。(預設是 ``None``。 )" #: ../../builtins/exceptions.rst:620 msgid "" @@ -724,6 +924,8 @@ msgid "" "inappropriate type. The associated value is a string giving details about " "the type mismatch." msgstr "" +"當一個操作或函式被用在不適合的型別的物件時會引發此例外。關聯值是一個字串,提" +"供關於不相符型別的細節。" #: ../../builtins/exceptions.rst:623 msgid "" @@ -732,6 +934,9 @@ msgid "" "object is meant to support a given operation but has not yet provided an " "implementation, :exc:`NotImplementedError` is the proper exception to raise." msgstr "" +"此例外可能被使用者程式碼引發,以表示並不支援物件上所嘗試的操作,且本來就無意" +"這樣做。如果一個物件有意要支援某個給定的操作但尚未提供實作,該引發的正確例外" +"是 :exc:`NotImplementedError`。" #: ../../builtins/exceptions.rst:628 msgid "" @@ -740,6 +945,9 @@ msgid "" "arguments with the wrong value (e.g. a number outside expected boundaries) " "should result in a :exc:`ValueError`." msgstr "" +"傳入錯誤型別的引數(例如當預期傳入 :class:`int` 卻傳入 :class:`list`)應該要" +"導致 :exc:`TypeError`,但傳入帶有錯誤值的引數(例如超出預期範圍的數值)應該要" +"導致 :exc:`ValueError`。" #: ../../builtins/exceptions.rst:635 msgid "" @@ -747,12 +955,16 @@ msgid "" "but no value has been bound to that variable. This is a subclass of :exc:" "`NameError`." msgstr "" +"當在函式或方法裡引用某個區域變數,但該變數尚未被繫結到任何值的時候會引發此例" +"外。這是 :exc:`NameError` 的子類別。" #: ../../builtins/exceptions.rst:642 msgid "" "Raised when a Unicode-related encoding or decoding error occurs. It is a " "subclass of :exc:`ValueError`." msgstr "" +"當 Unicode 相關的編碼或解碼錯誤發生時會引發此例外。這是 :exc:`ValueError` 的" +"子類別。" #: ../../builtins/exceptions.rst:645 msgid "" @@ -760,50 +972,59 @@ msgid "" "error. For example, ``err.object[err.start:err.end]`` gives the particular " "invalid input that the codec failed on." msgstr "" +":exc:`UnicodeError` 有屬性描述編碼或解碼錯誤。例如 ``err.object[err.start:" +"err.end]`` 會提供讓編解碼器失敗的具體無效輸入。" #: ../../builtins/exceptions.rst:651 msgid "The name of the encoding that raised the error." -msgstr "" +msgstr "引發錯誤的編碼名稱。" #: ../../builtins/exceptions.rst:655 msgid "A string describing the specific codec error." -msgstr "" +msgstr "描述特定編解碼器錯誤的字串。" #: ../../builtins/exceptions.rst:659 msgid "The object the codec was attempting to encode or decode." -msgstr "" +msgstr "編解碼器嘗試編碼或解碼的物件。" #: ../../builtins/exceptions.rst:663 msgid "The first index of invalid data in :attr:`object`." -msgstr "" +msgstr "在 :attr:`object` 中無效資料的開始索引。" #: ../../builtins/exceptions.rst:665 ../../builtins/exceptions.rst:672 msgid "" "This value should not be negative as it is interpreted as an absolute offset " "but this constraint is not enforced at runtime." msgstr "" +"此值不應為負,因為它被直譯為絕對偏移量,但此約束在 runtime 中不會被強制執行。" #: ../../builtins/exceptions.rst:670 msgid "The index after the last invalid data in :attr:`object`." -msgstr "" +msgstr "在 :attr:`object` 中最後的無效資料後的索引。" #: ../../builtins/exceptions.rst:678 msgid "" "Raised when a Unicode-related error occurs during encoding. It is a " "subclass of :exc:`UnicodeError`." msgstr "" +"在編碼當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" +"類別。" #: ../../builtins/exceptions.rst:684 msgid "" "Raised when a Unicode-related error occurs during decoding. It is a " "subclass of :exc:`UnicodeError`." msgstr "" +"在解碼當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" +"類別。" #: ../../builtins/exceptions.rst:690 msgid "" "Raised when a Unicode-related error occurs during translating. It is a " "subclass of :exc:`UnicodeError`." msgstr "" +"在轉譯當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" +"類別。" #: ../../builtins/exceptions.rst:696 msgid "" @@ -811,6 +1032,8 @@ msgid "" "type but an inappropriate value, and the situation is not described by a " "more precise exception such as :exc:`IndexError`." msgstr "" +"當一個操作或函式收到引數是正確型別但是不適合的值,且該情況無法被更精確的例外" +"例如 :exc:`IndexError` 所描述時會引發此例外。" #: ../../builtins/exceptions.rst:703 msgid "" @@ -818,26 +1041,30 @@ msgid "" "The associated value is a string indicating the type of the operands and the " "operation." msgstr "" +"當除法或模數運算 (modulo operation) 的第二個引數是 0 的時候會引發此例外。關聯" +"值是一個字串,表示運算元及運算的類型。" #: ../../builtins/exceptions.rst:708 msgid "" "The following exceptions are kept for compatibility with previous versions; " "starting from Python 3.3, they are aliases of :exc:`OSError`." msgstr "" +"以下例外是為了相容於之前版本而保留;從 Python 3.3 開始,它們是 :exc:" +"`OSError` 的別名。" #: ../../builtins/exceptions.rst:717 msgid "Only available on Windows." -msgstr "" +msgstr "僅限於在 Windows 中使用。" #: ../../builtins/exceptions.rst:721 msgid "OS exceptions" -msgstr "" +msgstr "作業系統例外" #: ../../builtins/exceptions.rst:723 msgid "" "The following exceptions are subclasses of :exc:`OSError`, they get raised " "depending on the system error code." -msgstr "" +msgstr "以下的例外是 :exc:`OSError` 的子類別,它們根據系統錯誤代碼來引發。" #: ../../builtins/exceptions.rst:728 msgid "" @@ -846,12 +1073,16 @@ msgid "" "EAGAIN`, :py:const:`~errno.EALREADY`, :py:const:`~errno.EWOULDBLOCK` and :py:" "const:`~errno.EINPROGRESS`." msgstr "" +"當設置為非阻塞操作的物件(例如 socket)上的操作將要阻塞時會引發此例外。對應" +"到 :c:data:`errno` :py:const:`~errno.EAGAIN`、:py:const:`~errno.EALREADY`、:" +"py:const:`~errno.EWOULDBLOCK` 及 :py:const:`~errno.EINPROGRESS`。" #: ../../builtins/exceptions.rst:733 msgid "" "In addition to those of :exc:`OSError`, :exc:`BlockingIOError` can have one " "more attribute:" msgstr "" +"除了 :exc:`OSError` 的那些屬性之外,:exc:`BlockingIOError` 有多一個屬性:" #: ../../builtins/exceptions.rst:738 msgid "" @@ -859,22 +1090,28 @@ msgid "" "it blocked. This attribute is available when using the buffered I/O classes " "from the :mod:`io` module." msgstr "" +"一個整數,內容為在其阻塞之前,已寫進串流的\\ **位元組**\\ 數。當使用 :mod:" +"`io` 模組裡的緩衝 I/O 類別時這個屬性是可用的。" #: ../../builtins/exceptions.rst:744 msgid "" "Raised when an operation on a child process failed. Corresponds to :c:data:" "`errno` :py:const:`~errno.ECHILD`." msgstr "" +"當子行程上的操作失敗時會引發此例外。對應到 :c:data:`errno` :py:const:`~errno." +"ECHILD`。" #: ../../builtins/exceptions.rst:749 msgid "A base class for connection-related issues." -msgstr "" +msgstr "連線相關問題的基礎類別。" #: ../../builtins/exceptions.rst:751 msgid "" "Subclasses are :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`, :exc:" "`ConnectionRefusedError` and :exc:`ConnectionResetError`." msgstr "" +"子類別有 :exc:`BrokenPipeError`、:exc:`ConnectionAbortedError`、:exc:" +"`ConnectionRefusedError` 及 :exc:`ConnectionResetError`。" #: ../../builtins/exceptions.rst:756 msgid "" @@ -883,6 +1120,9 @@ msgid "" "has been shutdown for writing. Corresponds to :c:data:`errno` :py:const:" "`~errno.EPIPE` and :py:const:`~errno.ESHUTDOWN`." msgstr "" +":exc:`ConnectionError` 的子類別,當嘗試寫入管道 (pipe) 同時另一端已經被關閉時" +"會引發此例外,或者當嘗試寫入已關閉寫入的 socket 時也會引發。對應到 :c:data:" +"`errno` :py:const:`~errno.EPIPE` 及 :py:const:`~errno.ESHUTDOWN`。" #: ../../builtins/exceptions.rst:763 msgid "" @@ -890,6 +1130,8 @@ msgid "" "aborted by the peer. Corresponds to :c:data:`errno` :py:const:`~errno." "ECONNABORTED`." msgstr "" +":exc:`ConnectionError` 的子類別。當一個連線的嘗試被對等端點 (peer) 中斷時會引" +"發此例外。對應到 :c:data:`errno` :py:const:`~errno.ECONNABORTED`。" #: ../../builtins/exceptions.rst:769 msgid "" @@ -897,30 +1139,40 @@ msgid "" "refused by the peer. Corresponds to :c:data:`errno` :py:const:`~errno." "ECONNREFUSED`." msgstr "" +":exc:`ConnectionError` 的子類別。當一個連線的嘗試被對等端點拒絕時會引發此例" +"外。對應到 :c:data:`errno` :py:const:`~errno.ECONNREFUSED`。" #: ../../builtins/exceptions.rst:775 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection is reset by " "the peer. Corresponds to :c:data:`errno` :py:const:`~errno.ECONNRESET`." msgstr "" +":exc:`ConnectionError` 的子類別。當一個連線被對等端點重置時會引發此例外。對應" +"到 :c:data:`errno` :py:const:`~errno.ECONNRESET`。" #: ../../builtins/exceptions.rst:781 msgid "" "Raised when trying to create a file or directory which already exists. " "Corresponds to :c:data:`errno` :py:const:`~errno.EEXIST`." msgstr "" +"當嘗試建立已存在的檔案或目錄時會引發此例外。對應到 :c:data:`errno` :py:const:" +"`~errno.EEXIST`。" #: ../../builtins/exceptions.rst:786 msgid "" "Raised when a file or directory is requested but doesn't exist. Corresponds " "to :c:data:`errno` :py:const:`~errno.ENOENT`." msgstr "" +"當請求不存在的檔案或目錄時會引發此例外。對應到 :c:data:`errno` :py:const:" +"`~errno.ENOENT`。" #: ../../builtins/exceptions.rst:791 msgid "" "Raised when a system call is interrupted by an incoming signal. Corresponds " "to :c:data:`errno` :py:const:`~errno.EINTR`." msgstr "" +"當系統呼叫被傳入的信號中斷時會引發此例外。對應到 :c:data:`errno` :py:const:" +"`~errno.EINTR`。" #: ../../builtins/exceptions.rst:794 msgid "" @@ -928,12 +1180,16 @@ msgid "" "except if the signal handler raises an exception (see :pep:`475` for the " "rationale), instead of raising :exc:`InterruptedError`." msgstr "" +"現在當 syscall 被信號中斷時 Python 會重試系統呼叫而不會引發 :exc:" +"`InterruptedError`,除非信號處理器引發例外(理由可參考 :pep:`475`)。" #: ../../builtins/exceptions.rst:801 msgid "" "Raised when a file operation (such as :func:`os.remove`) is requested on a " "directory. Corresponds to :c:data:`errno` :py:const:`~errno.EISDIR`." msgstr "" +"當在目錄上請求檔案操作(例如 :func:`os.remove`)時會引發此例外。對應到 :c:" +"data:`errno` :py:const:`~errno.EISDIR`。" #: ../../builtins/exceptions.rst:807 msgid "" @@ -943,6 +1199,9 @@ msgid "" "as if it were a directory. Corresponds to :c:data:`errno` :py:const:`~errno." "ENOTDIR`." msgstr "" +"當在某個不是目錄的東西上請求目錄操作(例如 :func:`os.listdir`)時會引發此例" +"外。在大多數的 POSIX 平台上,如果嘗試操作開啟或遍歷一個當作目錄的非目錄檔案也" +"會引發此例外。對應到 :c:data:`errno` :py:const:`~errno.ENOTDIR`。" #: ../../builtins/exceptions.rst:815 msgid "" @@ -951,56 +1210,65 @@ msgid "" "`~errno.EACCES`, :py:const:`~errno.EPERM`, and :py:const:`~errno." "ENOTCAPABLE`." msgstr "" +"當嘗試執行一個沒有合乎存取權限的操作時會引發此例外 — 例如檔案系統權限。對應" +"到 :c:data:`errno` :py:const:`~errno.EACCES`、:py:const:`~errno.EPERM` 及 :" +"py:const:`~errno.ENOTCAPABLE`。" #: ../../builtins/exceptions.rst:820 msgid "" "WASI's :py:const:`~errno.ENOTCAPABLE` is now mapped to :exc:" "`PermissionError`." msgstr "" +"WASI 的 :py:const:`~errno.ENOTCAPABLE` 現在對應到 :exc:`PermissionError`。" #: ../../builtins/exceptions.rst:826 msgid "" "Raised when a given process doesn't exist. Corresponds to :c:data:`errno` :" "py:const:`~errno.ESRCH`." msgstr "" +"當給定的行程不存在時會引發此例外。對應到 :c:data:`errno` :py:const:`~errno." +"ESRCH`。" #: ../../builtins/exceptions.rst:831 msgid "" "Raised when a system function timed out at the system level. Corresponds to :" "c:data:`errno` :py:const:`~errno.ETIMEDOUT`." msgstr "" +"當系統函式在系統層級超時會引發此例外。對應到 :c:data:`errno` :py:const:" +"`~errno.ETIMEDOUT`。" #: ../../builtins/exceptions.rst:834 msgid "All the above :exc:`OSError` subclasses were added." -msgstr "" +msgstr "加入以上所有的 :exc:`OSError` 子類別。" #: ../../builtins/exceptions.rst:840 msgid ":pep:`3151` - Reworking the OS and IO exception hierarchy" -msgstr "" +msgstr ":pep:`3151` — 改寫作業系統與 IO 例外階層" #: ../../builtins/exceptions.rst:846 msgid "Warnings" -msgstr "" +msgstr "警告" #: ../../builtins/exceptions.rst:848 msgid "" "The following exceptions are used as warning categories; see the :ref:" "`warning-categories` documentation for more details." msgstr "" +"以下的例外是當作警告的種類使用;更多細節參考 :ref:`warning-categories` 文件。" #: ../../builtins/exceptions.rst:853 msgid "Base class for warning categories." -msgstr "" +msgstr "警告種類的基礎類別。" #: ../../builtins/exceptions.rst:858 msgid "Base class for warnings generated by user code." -msgstr "" +msgstr "使用者程式碼產生的警告的基礎類別。" #: ../../builtins/exceptions.rst:863 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for other Python developers." -msgstr "" +msgstr "關於已棄用功能的警告的基礎類別,且當那些警告是針對其他 Python 開發者。" #: ../../builtins/exceptions.rst:866 msgid "" @@ -1008,16 +1276,18 @@ msgid "" "pep:`565`). Enabling the :ref:`Python Development Mode ` shows this " "warning." msgstr "" +"會被預設的警告過濾器忽略,在 ``__main__`` 模組裡除外 (:pep:`565`)。啟用 :ref:" +"`Python 開發模式 `\\ 會顯示此警告。" #: ../../builtins/exceptions.rst:870 ../../builtins/exceptions.rst:886 msgid "The deprecation policy is described in :pep:`387`." -msgstr "" +msgstr "棄用原則描述在 :pep:`387` 裡。" #: ../../builtins/exceptions.rst:875 msgid "" "Base class for warnings about features which are obsolete and expected to be " "deprecated in the future, but are not deprecated at the moment." -msgstr "" +msgstr "關於過時且預期未來要被棄用,但目前尚未被棄用的功能的警告的基礎類別。" #: ../../builtins/exceptions.rst:879 msgid "" @@ -1025,6 +1295,8 @@ msgid "" "deprecation is unusual, and :exc:`DeprecationWarning` is preferred for " "already active deprecations." msgstr "" +"因為發出關於可能即將被棄用的警告是不尋常的,此類別很少被使用,而對已經被棄用" +"的情況會優先使用 :exc:`DeprecationWarning`。" #: ../../builtins/exceptions.rst:883 ../../builtins/exceptions.rst:912 #: ../../builtins/exceptions.rst:939 @@ -1032,55 +1304,61 @@ msgid "" "Ignored by the default warning filters. Enabling the :ref:`Python " "Development Mode ` shows this warning." msgstr "" +"會被預設的警告過濾器忽略。啟用 :ref:`Python 開發模式 `\\ 會顯示此警" +"告。" #: ../../builtins/exceptions.rst:891 msgid "Base class for warnings about dubious syntax." -msgstr "" +msgstr "關於可疑語法的警告的基礎類別。" #: ../../builtins/exceptions.rst:893 msgid "" "This warning is typically emitted when compiling Python source code, and " "usually won't be reported when running already compiled code." msgstr "" +"此警告通常在編譯 Python 原始碼時發出,且通常不會在執行已編譯的程式碼時被回" +"報。" #: ../../builtins/exceptions.rst:899 msgid "Base class for warnings about dubious runtime behavior." -msgstr "" +msgstr "關於可疑執行環境行為的警告的基礎類別。" #: ../../builtins/exceptions.rst:904 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for end users of applications that are written in Python." msgstr "" +"關於已棄用功能的警告的基礎類別,且當那些警告是針對以 Python 寫的應用程式的終" +"端使用者。" #: ../../builtins/exceptions.rst:910 msgid "Base class for warnings about probable mistakes in module imports." -msgstr "" +msgstr "關於在模組引入的可能錯誤的警告的基礎類別。" #: ../../builtins/exceptions.rst:918 msgid "Base class for warnings related to Unicode." -msgstr "" +msgstr "Unicode 相關警告的基礎類別。" #: ../../builtins/exceptions.rst:923 msgid "Base class for warnings related to encodings." -msgstr "" +msgstr "編碼相關警告的基礎類別。" #: ../../builtins/exceptions.rst:925 msgid "See :ref:`io-encoding-warning` for details." -msgstr "" +msgstr "細節參考\\ :ref:`io-encoding-warning`。" #: ../../builtins/exceptions.rst:932 msgid "" "Base class for warnings related to :class:`bytes` and :class:`bytearray`." -msgstr "" +msgstr ":class:`bytes` 及 :class:`bytearray` 相關警告的基礎類別。" #: ../../builtins/exceptions.rst:937 msgid "Base class for warnings related to resource usage." -msgstr "" +msgstr "資源用法相關警告的基礎類別。" #: ../../builtins/exceptions.rst:948 msgid "Exception groups" -msgstr "" +msgstr "例外群組" #: ../../builtins/exceptions.rst:950 msgid "" @@ -1090,6 +1368,9 @@ msgid "" "recognised by :keyword:`except*`, which matches their subgroups " "based on the types of the contained exceptions." msgstr "" +"當需要引發多個不相關例外時會使用下列的類別。它們是例外階層的一部分所以可以像" +"所有其他例外一樣使用 :keyword:`except` 來處理。此外,它們會以包含的例外型別為" +"基礎來比對其子群組而被 :keyword:`except*` 辨認出來。" #: ../../builtins/exceptions.rst:959 msgid "" @@ -1101,6 +1382,11 @@ msgid "" "is so that ``except Exception`` catches an :exc:`ExceptionGroup` but not :" "exc:`BaseExceptionGroup`." msgstr "" +"這兩個例外型別都將例外包裝在序列 ``excs`` 中。``msg`` 參數必須是字串。這兩個" +"類別的差異是 :exc:`BaseExceptionGroup` 擴充了 :exc:`BaseException` 且可以包裝" +"任何例外,而 :exc:`ExceptionGroup` 擴充了 :exc:`Exception` 且只能包裝 :exc:" +"`Exception` 的子類別。這個設計使得 ``except Exception`` 可以捕捉 :exc:" +"`ExceptionGroup` 但不能捕捉 :exc:`BaseExceptionGroup`。" #: ../../builtins/exceptions.rst:967 msgid "" @@ -1110,12 +1396,16 @@ msgid "" "The :exc:`ExceptionGroup` constructor, on the other hand, raises a :exc:" "`TypeError` if any contained exception is not an :exc:`Exception` subclass." msgstr "" +"如果所有包含的例外都是 :exc:`Exception` 實例,:exc:`BaseExceptionGroup` 建構" +"函式會回傳 :exc:`ExceptionGroup` 而不是 :exc:`BaseExceptionGroup`,因此可以被" +"使用來讓這樣的選擇自動化。另一方面來說,如果任何包含的例外不是 :exc:" +"`Exception` 的子類別,:exc:`ExceptionGroup` 建構函式會引發 :exc:`TypeError`。" #: ../../builtins/exceptions.rst:974 msgid "" "Exception groups are :ref:`generic ` over the type of their " "contained exceptions." -msgstr "" +msgstr "例外群組對其所包含例外的型別是\\ :ref:`泛型 `\\ 的。" #: ../../builtins/exceptions.rst:979 msgid "" @@ -1123,22 +1413,26 @@ msgid "" "specifically processed more efficiently here. For optimal performance, pass " "a tuple as ``excs``." msgstr "" +"``excs`` 參數可以是任意序列,但串列和元組在這裡會被特別更有效率地處理。若要獲" +"得最佳效能,請將元組作為 ``excs`` 傳入。" #: ../../builtins/exceptions.rst:985 msgid "The ``msg`` argument to the constructor. This is a read-only attribute." -msgstr "" +msgstr "建構函式的 ``msg`` 引數。這是一個唯讀的屬性。" #: ../../builtins/exceptions.rst:989 msgid "" "A tuple of the exceptions in the ``excs`` sequence given to the constructor. " "This is a read-only attribute." -msgstr "" +msgstr "指定給建構函式 ``excs`` 序列中的例外組成的元組。這是一個唯讀的屬性。" #: ../../builtins/exceptions.rst:994 msgid "" "Returns an exception group that contains only the exceptions from the " "current group that match *condition*, or ``None`` if the result is empty." msgstr "" +"回傳只包含從現有群組比對到 *condition* 的例外的例外群組,或者當結果為空時回" +"傳 ``None``。" #: ../../builtins/exceptions.rst:997 msgid "" @@ -1148,6 +1442,10 @@ msgid "" "type object) that accepts an exception as its single argument and returns " "true for the exceptions that should be in the subgroup." msgstr "" +"條件式可以是一個例外型別或是例外型別的元組,在此情況下,每個例外都會使用與 " +"``except`` 子句中使用的相同檢查方法來檢查是否有匹配。條件式也可以是一個可呼叫" +"物件(除了型別物件之外),其接受一個例外作為單一引數,而如果該例外應該在子群" +"組中就回傳 true。" #: ../../builtins/exceptions.rst:1003 msgid "" @@ -1157,6 +1455,10 @@ msgid "" "__context__` and :attr:`~BaseException.__notes__` fields. Empty nested " "groups are omitted from the result." msgstr "" +"現有例外的巢狀結構會保留在結果裡,其 :attr:`message`、:attr:`~BaseException." +"__traceback__`、:attr:`~BaseException.__cause__`、:attr:`~BaseException." +"__context__` 及 :attr:`~BaseException.__notes__` 欄位的值也一樣。空的巢狀群組" +"會從結果裡排除。" #: ../../builtins/exceptions.rst:1010 msgid "" @@ -1164,10 +1466,12 @@ msgid "" "including the top-level and any nested exception groups. If the condition is " "true for such an exception group, it is included in the result in full." msgstr "" +"條件會對巢狀例外群組裡的所有例外做檢查,包括頂層及任何巢狀的例外群組。如果條" +"件對這樣的例外群組為 true,它會被完整包含在結果裡。" #: ../../builtins/exceptions.rst:1014 msgid "``condition`` can be any callable which is not a type object." -msgstr "" +msgstr "``condition`` 可以是任何不是型別物件的可呼叫物件。" #: ../../builtins/exceptions.rst:1019 msgid "" @@ -1175,12 +1479,14 @@ msgid "" "``match`` is ``subgroup(condition)`` and ``rest`` is the remaining non-" "matching part." msgstr "" +"像 :meth:`subgroup` 一樣,但回傳一對 ``(match, rest)``,其中 ``match`` 是 " +"``subgroup(condition)`` 而 ``rest`` 是剩下沒有比對到的部分。" #: ../../builtins/exceptions.rst:1025 msgid "" "Returns an exception group with the same :attr:`message`, but which wraps " "the exceptions in ``excs``." -msgstr "" +msgstr "回傳有相同 :attr:`message` 但將例外包裝在 ``excs`` 的例外群組。" #: ../../builtins/exceptions.rst:1028 msgid "" @@ -1189,6 +1495,9 @@ msgid "" "override it in order to make :meth:`subgroup` and :meth:`split` return " "instances of the subclass rather than :exc:`ExceptionGroup`." msgstr "" +"此方法被 :meth:`subgroup` 及 :meth:`split` 使用,被用來在各種情境下拆分例外群" +"組。子類別需要覆寫它來讓 :meth:`subgroup` 及 :meth:`split` 回傳子類別而不是 :" +"exc:`ExceptionGroup` 的實例。" #: ../../builtins/exceptions.rst:1034 msgid "" @@ -1198,6 +1507,10 @@ msgid "" "exception group to the one returned by :meth:`derive`, so these fields do " "not need to be updated by :meth:`derive`." msgstr "" +":meth:`subgroup` 及 :meth:`split` 會從原始的例外群組複製 :attr:" +"`~BaseException.__traceback__`、:attr:`~BaseException.__cause__`、:attr:" +"`~BaseException.__context__` 和 :attr:`~BaseException.__notes__` 欄位到 :" +"meth:`derive` 所回傳的例外群組上,因此這些欄位不需要被 :meth:`derive` 更新。" #: ../../builtins/exceptions.rst:1041 msgid "" @@ -1227,6 +1540,31 @@ msgid "" ">>> exc.__traceback__ is match.__traceback__ is rest.__traceback__\n" "True" msgstr "" +">>> class MyGroup(ExceptionGroup):\n" +"... def derive(self, excs):\n" +"... return MyGroup(self.message, excs)\n" +"...\n" +">>> e = MyGroup(\"eg\", [ValueError(1), TypeError(2)])\n" +">>> e.add_note(\"a note\")\n" +">>> e.__context__ = Exception(\"context\")\n" +">>> e.__cause__ = Exception(\"cause\")\n" +">>> try:\n" +"... raise e\n" +"... except Exception as e:\n" +"... exc = e\n" +"...\n" +">>> match, rest = exc.split(ValueError)\n" +">>> exc, exc.__context__, exc.__cause__, exc.__notes__\n" +"(MyGroup('eg', [ValueError(1), TypeError(2)]), Exception('context'), " +"Exception('cause'), ['a note'])\n" +">>> match, match.__context__, match.__cause__, match.__notes__\n" +"(MyGroup('eg', [ValueError(1)]), Exception('context'), Exception('cause'), " +"['a note'])\n" +">>> rest, rest.__context__, rest.__cause__, rest.__notes__\n" +"(MyGroup('eg', [TypeError(2)]), Exception('context'), Exception('cause'), " +"['a note'])\n" +">>> exc.__traceback__ is match.__traceback__ is rest.__traceback__\n" +"True" #: ../../builtins/exceptions.rst:1067 msgid "" @@ -1236,6 +1574,9 @@ msgid "" "exception group subclass which accepts an exit_code and constructs the " "group's message from it. ::" msgstr "" +"需注意 :exc:`BaseExceptionGroup` 定義了 :meth:`~object.__new__`,因此需要不同" +"建構函式簽名的子類別需要覆寫它而不是 :meth:`~object.__init__`。例如下面定義了" +"一個例外群組子類別接受 exit_code 並從中建構群組的訊息。: ::" #: ../../builtins/exceptions.rst:1073 msgid "" @@ -1248,6 +1589,14 @@ msgid "" " def derive(self, excs):\n" " return Errors(excs, self.exit_code)" msgstr "" +"class Errors(ExceptionGroup):\n" +" def __new__(cls, errors, exit_code):\n" +" self = super().__new__(Errors, f\"exit code: {exit_code}\", errors)\n" +" self.exit_code = exit_code\n" +" return self\n" +"\n" +" def derive(self, excs):\n" +" return Errors(excs, self.exit_code)" #: ../../builtins/exceptions.rst:1082 msgid "" @@ -1255,14 +1604,16 @@ msgid "" "is also a subclass of :exc:`Exception` can only wrap instances of :exc:" "`Exception`." msgstr "" +"像 :exc:`ExceptionGroup` 一樣,任何 :exc:`BaseExceptionGroup` 的子類別且也" +"是 :exc:`Exception` 的子類別只能包裝 :exc:`Exception` 的實例。" #: ../../builtins/exceptions.rst:1090 msgid "Exception hierarchy" -msgstr "" +msgstr "例外階層" #: ../../builtins/exceptions.rst:1092 msgid "The class hierarchy for built-in exceptions is:" -msgstr "" +msgstr "內建例外的類別階層如下:" #: ../../builtins/exceptions.rst:1094 msgid "" @@ -1335,52 +1686,120 @@ msgid "" " ├── UnicodeWarning\n" " └── UserWarning\n" msgstr "" +"BaseException\n" +" ├── BaseExceptionGroup\n" +" ├── GeneratorExit\n" +" ├── KeyboardInterrupt\n" +" ├── SystemExit\n" +" └── Exception\n" +" ├── ArithmeticError\n" +" │ ├── FloatingPointError\n" +" │ ├── OverflowError\n" +" │ └── ZeroDivisionError\n" +" ├── AssertionError\n" +" ├── AttributeError\n" +" ├── BufferError\n" +" ├── EOFError\n" +" ├── ExceptionGroup [BaseExceptionGroup]\n" +" ├── ImportError\n" +" │ └── ModuleNotFoundError\n" +" ├── LookupError\n" +" │ ├── IndexError\n" +" │ └── KeyError\n" +" ├── MemoryError\n" +" ├── NameError\n" +" │ └── UnboundLocalError\n" +" ├── OSError\n" +" │ ├── BlockingIOError\n" +" │ ├── ChildProcessError\n" +" │ ├── ConnectionError\n" +" │ │ ├── BrokenPipeError\n" +" │ │ ├── ConnectionAbortedError\n" +" │ │ ├── ConnectionRefusedError\n" +" │ │ └── ConnectionResetError\n" +" │ ├── FileExistsError\n" +" │ ├── FileNotFoundError\n" +" │ ├── InterruptedError\n" +" │ ├── IsADirectoryError\n" +" │ ├── NotADirectoryError\n" +" │ ├── PermissionError\n" +" │ ├── ProcessLookupError\n" +" │ └── TimeoutError\n" +" ├── ReferenceError\n" +" ├── RuntimeError\n" +" │ ├── NotImplementedError\n" +" │ ├── PythonFinalizationError\n" +" │ └── RecursionError\n" +" ├── StopAsyncIteration\n" +" ├── StopIteration\n" +" ├── SyntaxError\n" +" │ └── IndentationError\n" +" │ └── TabError\n" +" ├── SystemError\n" +" ├── TypeError\n" +" ├── ValueError\n" +" │ └── UnicodeError\n" +" │ ├── UnicodeDecodeError\n" +" │ ├── UnicodeEncodeError\n" +" │ └── UnicodeTranslateError\n" +" └── Warning\n" +" ├── BytesWarning\n" +" ├── DeprecationWarning\n" +" ├── EncodingWarning\n" +" ├── FutureWarning\n" +" ├── ImportWarning\n" +" ├── PendingDeprecationWarning\n" +" ├── ResourceWarning\n" +" ├── RuntimeWarning\n" +" ├── SyntaxWarning\n" +" ├── UnicodeWarning\n" +" └── UserWarning\n" #: ../../builtins/exceptions.rst:6 ../../builtins/exceptions.rst:17 #: ../../builtins/exceptions.rst:196 msgid "statement" -msgstr "" +msgstr "statement(陳述式)" #: ../../builtins/exceptions.rst:6 msgid "try" -msgstr "" +msgstr "try" #: ../../builtins/exceptions.rst:6 msgid "except" -msgstr "" +msgstr "except" #: ../../builtins/exceptions.rst:17 msgid "raise" -msgstr "" +msgstr "raise" #: ../../builtins/exceptions.rst:41 msgid "exception" -msgstr "" +msgstr "exception(例外)" #: ../../builtins/exceptions.rst:41 msgid "chaining" -msgstr "" +msgstr "chaining" #: ../../builtins/exceptions.rst:41 msgid "__cause__ (exception attribute)" -msgstr "" +msgstr "__cause__(例外屬性)" #: ../../builtins/exceptions.rst:41 msgid "__context__ (exception attribute)" -msgstr "" +msgstr "__context__(例外屬性)" #: ../../builtins/exceptions.rst:41 msgid "__suppress_context__ (exception attribute)" -msgstr "" +msgstr "__suppress_context__(例外屬性)" #: ../../builtins/exceptions.rst:196 msgid "assert" -msgstr "" +msgstr "assert" #: ../../builtins/exceptions.rst:355 msgid "module" -msgstr "" +msgstr "module(模組)" #: ../../builtins/exceptions.rst:355 msgid "errno" -msgstr "" +msgstr "errno" diff --git a/builtins/functions.po b/builtins/functions.po index 0b485f8320..b5e2788c80 100644 --- a/builtins/functions.po +++ b/builtins/functions.po @@ -19,377 +19,378 @@ msgstr "" #: ../../builtins/functions.rst:5 ../../builtins/functions.rst:11 msgid "Built-in Functions" -msgstr "" +msgstr "內建函式" #: ../../builtins/functions.rst:7 msgid "" "The Python interpreter has a number of functions and types built into it " "that are always available. They are listed here in alphabetical order." msgstr "" +"Python 直譯器有內建多個可隨時使用的函式和型別。以下按照英文字母排序列出。" #: ../../builtins/functions.rst:0 msgid "**A**" -msgstr "" +msgstr "**A**" #: ../../builtins/functions.rst:0 msgid ":func:`abs`" -msgstr "" +msgstr ":func:`abs`" #: ../../builtins/functions.rst:0 msgid ":func:`aiter`" -msgstr "" +msgstr ":func:`aiter`" #: ../../builtins/functions.rst:0 msgid ":func:`all`" -msgstr "" +msgstr ":func:`all`" #: ../../builtins/functions.rst:0 msgid ":func:`anext`" -msgstr "" +msgstr ":func:`anext`" #: ../../builtins/functions.rst:0 msgid ":func:`any`" -msgstr "" +msgstr ":func:`any`" #: ../../builtins/functions.rst:0 msgid ":func:`ascii`" -msgstr "" +msgstr ":func:`ascii`" #: ../../builtins/functions.rst:0 msgid "**B**" -msgstr "" +msgstr "**B**" #: ../../builtins/functions.rst:0 msgid ":func:`bin`" -msgstr "" +msgstr ":func:`bin`" #: ../../builtins/functions.rst:0 msgid ":func:`bool`" -msgstr "" +msgstr ":func:`bool`" #: ../../builtins/functions.rst:0 msgid ":func:`breakpoint`" -msgstr "" +msgstr ":func:`breakpoint`" #: ../../builtins/functions.rst:0 msgid "|func-bytearray|_" -msgstr "" +msgstr "|func-bytearray|_" #: ../../builtins/functions.rst:0 msgid "|func-bytes|_" -msgstr "" +msgstr "|func-bytes|_" #: ../../builtins/functions.rst:0 msgid "**C**" -msgstr "" +msgstr "**C**" #: ../../builtins/functions.rst:0 msgid ":func:`callable`" -msgstr "" +msgstr ":func:`callable`" #: ../../builtins/functions.rst:0 msgid ":func:`chr`" -msgstr "" +msgstr ":func:`chr`" #: ../../builtins/functions.rst:0 msgid ":func:`classmethod`" -msgstr "" +msgstr ":func:`classmethod`" #: ../../builtins/functions.rst:0 msgid ":func:`compile`" -msgstr "" +msgstr ":func:`compile`" #: ../../builtins/functions.rst:0 msgid ":func:`complex`" -msgstr "" +msgstr ":func:`complex`" #: ../../builtins/functions.rst:0 msgid "**D**" -msgstr "" +msgstr "**D**" #: ../../builtins/functions.rst:0 msgid ":func:`delattr`" -msgstr "" +msgstr ":func:`delattr`" #: ../../builtins/functions.rst:0 msgid "|func-dict|_" -msgstr "" +msgstr "|func-dict|_" #: ../../builtins/functions.rst:0 msgid ":func:`dir`" -msgstr "" +msgstr ":func:`dir`" #: ../../builtins/functions.rst:0 msgid ":func:`divmod`" -msgstr "" +msgstr ":func:`divmod`" #: ../../builtins/functions.rst:0 msgid "**E**" -msgstr "" +msgstr "**E**" #: ../../builtins/functions.rst:0 msgid ":func:`enumerate`" -msgstr "" +msgstr ":func:`enumerate`" #: ../../builtins/functions.rst:0 msgid ":func:`eval`" -msgstr "" +msgstr ":func:`eval`" #: ../../builtins/functions.rst:0 msgid ":func:`exec`" -msgstr "" +msgstr ":func:`exec`" #: ../../builtins/functions.rst:0 msgid "**F**" -msgstr "" +msgstr "**F**" #: ../../builtins/functions.rst:0 msgid ":func:`filter`" -msgstr "" +msgstr ":func:`filter`" #: ../../builtins/functions.rst:0 msgid ":func:`float`" -msgstr "" +msgstr ":func:`float`" #: ../../builtins/functions.rst:0 msgid ":func:`format`" -msgstr "" +msgstr ":func:`format`" #: ../../builtins/functions.rst:0 msgid "|func-frozenset|_" -msgstr "" +msgstr "|func-frozenset|_" #: ../../builtins/functions.rst:0 msgid "**G**" -msgstr "" +msgstr "**G**" #: ../../builtins/functions.rst:0 msgid ":func:`getattr`" -msgstr "" +msgstr ":func:`getattr`" #: ../../builtins/functions.rst:0 msgid ":func:`globals`" -msgstr "" +msgstr ":func:`globals`" #: ../../builtins/functions.rst:0 msgid "**H**" -msgstr "" +msgstr "**H**" #: ../../builtins/functions.rst:0 msgid ":func:`hasattr`" -msgstr "" +msgstr ":func:`hasattr`" #: ../../builtins/functions.rst:0 msgid ":func:`hash`" -msgstr "" +msgstr ":func:`hash`" #: ../../builtins/functions.rst:0 msgid ":func:`help`" -msgstr "" +msgstr ":func:`help`" #: ../../builtins/functions.rst:0 msgid ":func:`hex`" -msgstr "" +msgstr ":func:`hex`" #: ../../builtins/functions.rst:0 msgid "**I**" -msgstr "" +msgstr "**I**" #: ../../builtins/functions.rst:0 msgid ":func:`id`" -msgstr "" +msgstr ":func:`id`" #: ../../builtins/functions.rst:0 msgid ":func:`input`" -msgstr "" +msgstr ":func:`input`" #: ../../builtins/functions.rst:0 msgid ":func:`int`" -msgstr "" +msgstr ":func:`int`" #: ../../builtins/functions.rst:0 msgid ":func:`isinstance`" -msgstr "" +msgstr ":func:`isinstance`" #: ../../builtins/functions.rst:0 msgid ":func:`issubclass`" -msgstr "" +msgstr ":func:`issubclass`" #: ../../builtins/functions.rst:0 msgid ":func:`iter`" -msgstr "" +msgstr ":func:`iter`" #: ../../builtins/functions.rst:0 msgid "**L**" -msgstr "" +msgstr "**L**" #: ../../builtins/functions.rst:0 msgid ":func:`len`" -msgstr "" +msgstr ":func:`len`" #: ../../builtins/functions.rst:0 msgid "|func-list|_" -msgstr "" +msgstr "|func-list|_" #: ../../builtins/functions.rst:0 msgid ":func:`locals`" -msgstr "" +msgstr ":func:`locals`" #: ../../builtins/functions.rst:0 msgid "**M**" -msgstr "" +msgstr "**M**" #: ../../builtins/functions.rst:0 msgid ":func:`map`" -msgstr "" +msgstr ":func:`map`" #: ../../builtins/functions.rst:0 msgid ":func:`max`" -msgstr "" +msgstr ":func:`max`" #: ../../builtins/functions.rst:0 msgid "|func-memoryview|_" -msgstr "" +msgstr "|func-memoryview|_" #: ../../builtins/functions.rst:0 msgid ":func:`min`" -msgstr "" +msgstr ":func:`min`" #: ../../builtins/functions.rst:0 msgid "**N**" -msgstr "" +msgstr "**N**" #: ../../builtins/functions.rst:0 msgid ":func:`next`" -msgstr "" +msgstr ":func:`next`" #: ../../builtins/functions.rst:0 msgid "**O**" -msgstr "" +msgstr "**O**" #: ../../builtins/functions.rst:0 msgid ":func:`object`" -msgstr "" +msgstr ":func:`object`" #: ../../builtins/functions.rst:0 msgid ":func:`oct`" -msgstr "" +msgstr ":func:`oct`" #: ../../builtins/functions.rst:0 msgid ":func:`open`" -msgstr "" +msgstr ":func:`open`" #: ../../builtins/functions.rst:0 msgid ":func:`ord`" -msgstr "" +msgstr ":func:`ord`" #: ../../builtins/functions.rst:0 msgid "**P**" -msgstr "" +msgstr "**P**" #: ../../builtins/functions.rst:0 msgid ":func:`pow`" -msgstr "" +msgstr ":func:`pow`" #: ../../builtins/functions.rst:0 msgid ":func:`print`" -msgstr "" +msgstr ":func:`print`" #: ../../builtins/functions.rst:0 msgid ":func:`property`" -msgstr "" +msgstr ":func:`property`" #: ../../builtins/functions.rst:0 msgid "**R**" -msgstr "" +msgstr "**R**" #: ../../builtins/functions.rst:0 msgid "|func-range|_" -msgstr "" +msgstr "|func-range|_" #: ../../builtins/functions.rst:0 msgid ":func:`repr`" -msgstr "" +msgstr ":func:`repr`" #: ../../builtins/functions.rst:0 msgid ":func:`reversed`" -msgstr "" +msgstr ":func:`reversed`" #: ../../builtins/functions.rst:0 msgid ":func:`round`" -msgstr "" +msgstr ":func:`round`" #: ../../builtins/functions.rst:0 msgid "**S**" -msgstr "" +msgstr "**S**" #: ../../builtins/functions.rst:0 msgid "|func-set|_" -msgstr "" +msgstr "|func-set|_" #: ../../builtins/functions.rst:0 msgid ":func:`setattr`" -msgstr "" +msgstr ":func:`setattr`" #: ../../builtins/functions.rst:0 msgid ":func:`slice`" -msgstr "" +msgstr ":func:`slice`" #: ../../builtins/functions.rst:0 msgid ":func:`sorted`" -msgstr "" +msgstr ":func:`sorted`" #: ../../builtins/functions.rst:0 msgid ":func:`staticmethod`" -msgstr "" +msgstr ":func:`staticmethod`" #: ../../builtins/functions.rst:0 msgid "|func-str|_" -msgstr "" +msgstr "|func-str|_" #: ../../builtins/functions.rst:0 msgid ":func:`sum`" -msgstr "" +msgstr ":func:`sum`" #: ../../builtins/functions.rst:0 msgid ":func:`super`" -msgstr "" +msgstr ":func:`super`" #: ../../builtins/functions.rst:0 msgid "**T**" -msgstr "" +msgstr "**T**" #: ../../builtins/functions.rst:0 msgid "|func-tuple|_" -msgstr "" +msgstr "|func-tuple|_" #: ../../builtins/functions.rst:0 msgid ":func:`type`" -msgstr "" +msgstr ":func:`type`" #: ../../builtins/functions.rst:0 msgid "**V**" -msgstr "" +msgstr "**V**" #: ../../builtins/functions.rst:0 msgid ":func:`vars`" -msgstr "" +msgstr ":func:`vars`" #: ../../builtins/functions.rst:0 msgid "**Z**" -msgstr "" +msgstr "**Z**" #: ../../builtins/functions.rst:0 msgid ":func:`zip`" -msgstr "" +msgstr ":func:`zip`" #: ../../builtins/functions.rst:0 msgid "**_**" -msgstr "" +msgstr "**_**" #: ../../builtins/functions.rst:0 msgid ":func:`__import__`" -msgstr "" +msgstr ":func:`__import__`" #: ../../builtins/functions.rst:59 msgid "" @@ -397,22 +398,28 @@ msgid "" "floating-point number, or an object implementing :meth:`~object.__abs__`. If " "the argument is a complex number, its magnitude is returned." msgstr "" +"回傳一個數的絕對值,引數可以是整數、浮點數或有實現 :meth:`~object.__abs__` 的" +"物件。如果引數是一個複數,回傳它的純量(大小)。" #: ../../builtins/functions.rst:67 msgid "" "Return an :term:`asynchronous iterator` for an :term:`asynchronous " "iterable`. Equivalent to calling ``x.__aiter__()``." msgstr "" +"回傳 :term:`非同步疊代器 ` 做為 :term:`非同步可疊代物" +"件 `。相當於呼叫 x.__aiter__()。" #: ../../builtins/functions.rst:70 msgid "Note: Unlike :func:`iter`, :func:`aiter` has no 2-argument variant." -msgstr "" +msgstr "注意:與 :func:`iter` 不同,:func:`aiter` 沒有兩個引數的變體。" #: ../../builtins/functions.rst:76 msgid "" "Return ``True`` if all elements of the *iterable* are true (or if the " "iterable is empty). Equivalent to::" msgstr "" +"如果 *iterable* 的所有元素皆為真(或 iterable 為空)則回傳 ``True``。等價" +"於: ::" #: ../../builtins/functions.rst:79 msgid "" @@ -422,17 +429,25 @@ msgid "" " return False\n" " return True" msgstr "" +"def all(iterable):\n" +" for element in iterable:\n" +" if not element:\n" +" return False\n" +" return True" #: ../../builtins/functions.rst:89 msgid "" "When awaited, return the next item from the given :term:`asynchronous " "iterator`, or *default* if given and the iterator is :term:`exhausted`." msgstr "" +"當進入 await 時,回傳給定的 :term:`asynchronous iterator` 的下一個項目;如果" +"該疊代器已\\ :term:`耗盡 `\\ 且有提供 *default*,則回傳 " +"*default*。" #: ../../builtins/functions.rst:92 msgid "" "This is the async variant of the :func:`next` builtin, and behaves similarly." -msgstr "" +msgstr "這是內建函式 :func:`next` 的非同步版本,其行為類似於:" #: ../../builtins/functions.rst:95 msgid "" @@ -441,12 +456,17 @@ msgid "" "iterator. If *default* is given, it is returned if the iterator is " "exhausted, otherwise :exc:`StopAsyncIteration` is raised." msgstr "" +"呼叫 *async_iterator* 的 :meth:`~object.__anext__` 方法,回傳 :term:" +"`awaitable`。等待回傳疊代器的下一個值。如果指定 *default*,當疊代器結束時會回" +"傳該值,否則會引發 :exc:`StopAsyncIteration` 。" #: ../../builtins/functions.rst:104 msgid "" "Return ``True`` if any element of the *iterable* is true. If the iterable " "is empty, return ``False``. Equivalent to::" msgstr "" +"如果 *iterable* 的任一元素為真,回傳 ``True``。如果 iterable 是空的,則回傳 " +"``False``。等價於: ::" #: ../../builtins/functions.rst:107 msgid "" @@ -456,6 +476,11 @@ msgid "" " return True\n" " return False" msgstr "" +"def any(iterable):\n" +" for element in iterable:\n" +" if element:\n" +" return True\n" +" return False" #: ../../builtins/functions.rst:116 msgid "" @@ -464,6 +489,9 @@ msgid "" "`repr` using ``\\x``, ``\\u``, or ``\\U`` escapes. This generates a string " "similar to that returned by :func:`repr` in Python 2." msgstr "" +"就像函式 :func:`repr`,回傳一個表示物件的字串,但是 :func:`repr` 回傳的字串中" +"非 ASCII 編碼的字元會被跳脫 (escape),像是 ``\\x``、``\\u`` 和 ``\\U``。這個" +"函式生成的字串和 Python 2 的 :func:`repr` 回傳的結果相似。" #: ../../builtins/functions.rst:124 msgid "" @@ -472,22 +500,25 @@ msgid "" "`int` object, it has to define an :meth:`~object.__index__` method that " "returns an integer. Some examples:" msgstr "" +"將一個整數轉變為一個前綴為 \"0b\" 的二進位制字串。結果是一個有效的 Python 運" +"算式。如果 *integer* 不是 Python 的 :class:`int` 物件,那它需要定義 :meth:" +"`~object.__index__` method 回傳一個整數。舉例來說:" #: ../../builtins/functions.rst:134 msgid "" "If the prefix \"0b\" is desired or not, you can use either of the following " "ways." -msgstr "" +msgstr "如果不一定需要 \"0b\" 前綴,還可以使用如下的方法。" #: ../../builtins/functions.rst:141 msgid "" "See also :func:`enum.bin` to represent negative values as twos-complement." -msgstr "" +msgstr "也請參閱 :func:`enum.bin` 以二補數表示負數。" #: ../../builtins/functions.rst:143 ../../builtins/functions.rst:956 #: ../../builtins/functions.rst:1340 msgid "See also :func:`format` for more information." -msgstr "" +msgstr "可參考 :func:`format` 取得更多資訊。" #: ../../builtins/functions.rst:148 msgid "" @@ -498,10 +529,15 @@ msgid "" "`typesnumeric`). It cannot be subclassed further. Its only instances are " "``False`` and ``True`` (see :ref:`typebool`)." msgstr "" +"回傳一個布林值,即 ``True`` 或者 ``False``。引數會使用標準的\\ :ref:`真值測試" +"程序 `\\ 來轉換。如果引數為假或者被省略,則回傳 ``False``;其他情況回" +"傳 ``True``。:class:`bool` class(類別)是 :class:`int` 的 subclass(子類別)" +"(參見 :ref:`typesnumeric`),其他 class 不能繼承自它。它只有 ``False`` 和 " +"``True`` 兩個實例(參見 :ref:`typebool`)。" #: ../../builtins/functions.rst:158 ../../builtins/functions.rst:821 msgid "The parameter is now positional-only." -msgstr "" +msgstr "現在為僅限位置參數。" #: ../../builtins/functions.rst:163 msgid "" @@ -515,6 +551,13 @@ msgid "" "you to drop into the debugger of choice. If :func:`sys.breakpointhook` is " "not accessible, this function will raise :exc:`RuntimeError`." msgstr "" +"這個函式將呼叫 :func:`sys.breakpointhook` 函式,並將 ``args`` 和 ``kws`` 傳遞" +"給它。這將有效地讓你在特定的呼叫點進入除錯器。預設情況下,``sys." +"breakpointhook()`` 呼叫 :func:`pdb.set_trace` 不須帶任何引數。這樣的設計是為" +"了方便使用者,讓他們不需要額外地導入 :mod:`pdb` 模組或輸入太多程式就可以進入" +"除錯器。然而,可以將 :func:`sys.breakpointhook` 設置為其他函式,並且 :func:" +"`breakpoint` 將自動呼叫該函式,讓你進入所選擇的除錯器。如果無法存取 :func:" +"`sys.breakpointhook` 這個函式,則此函式將引發 :exc:`RuntimeError`。" #: ../../builtins/functions.rst:175 msgid "" @@ -522,18 +565,22 @@ msgid "" "envvar:`PYTHONBREAKPOINT` environment variable. See :func:`sys." "breakpointhook` for usage details." msgstr "" +"預設情況下,:func:`breakpoint` 的行為可以透過 :envvar:`PYTHONBREAKPOINT` 環境" +"變數來更改。有關使用詳情,請參考 :func:`sys.breakpointhook`。" #: ../../builtins/functions.rst:179 msgid "" "Note that this is not guaranteed if :func:`sys.breakpointhook` has been " "replaced." -msgstr "" +msgstr "請注意,如果 :func:`sys.breakpointhook` 被替換了,則無法保證此功能。" #: ../../builtins/functions.rst:182 msgid "" "Raises an :ref:`auditing event ` ``builtins.breakpoint`` with " "argument ``breakpointhook``." msgstr "" +"引發一個附帶引數 ``breakpointhook`` 的\\ :ref:`稽核事件 ` " +"``builtins.breakpoint``。" #: ../../builtins/functions.rst:191 msgid "" @@ -542,12 +589,16 @@ msgid "" "methods of mutable sequences, described in :ref:`typesseq-mutable`, as well " "as most methods that the :class:`bytes` type has, see :ref:`bytes-methods`." msgstr "" +"回傳一個新的 bytes 陣列。:class:`bytearray` class 是一個可變的整數序列,包含" +"範圍為 0 <= x < 256 的整數。它有可變序列大部分常見的 method(如在 :ref:" +"`typesseq-mutable` 中所述),同時也有 :class:`bytes` 型別大部分的 method,參" +"見 :ref:`bytes-methods`。" #: ../../builtins/functions.rst:196 msgid "" "The optional *source* parameter can be used to initialize the array in a few " "different ways:" -msgstr "" +msgstr "選擇性參數 *source* 可以被用來以不同的方式初始化陣列:" #: ../../builtins/functions.rst:199 msgid "" @@ -555,12 +606,16 @@ msgid "" "*errors*) parameters; :func:`bytearray` then converts the string to bytes " "using :meth:`str.encode`." msgstr "" +"如果是一個 *string*,你必須提供 *encoding* 參數(以及選擇性地提供 " +"*errors* );:func:`bytearray` 會使用 :meth:`str.encode` method 來將 string " +"轉變成 bytes。" #: ../../builtins/functions.rst:203 msgid "" "If it is an *integer*, the array will have that size and will be initialized " "with null bytes." msgstr "" +"如果是一個 *integer*,陣列則會有該數值的長度,並以 null bytes 來當作初始值。" #: ../../builtins/functions.rst:206 msgid "" @@ -568,20 +623,24 @@ msgid "" "`, a read-only buffer of the object will be used to " "initialize the bytes array." msgstr "" +"如果是一個符合 :ref:`buffer 介面 `\\ 的物件,該物件的唯讀 " +"buffer 會被用來初始化 bytes 陣列。" #: ../../builtins/functions.rst:209 msgid "" "If it is an *iterable*, it must be an iterable of integers in the range ``0 " "<= x < 256``, which are used as the initial contents of the array." msgstr "" +"如果是一個 *iterable*,它的元素必須是範圍為 ``0 <= x < 256`` 的整數,並且會被" +"用作陣列的初始值。" #: ../../builtins/functions.rst:212 msgid "Without an argument, an array of size 0 is created." -msgstr "" +msgstr "如果沒有引數,則建立長度為 0 的陣列。" #: ../../builtins/functions.rst:214 msgid "See also :ref:`binaryseq` and :ref:`typebytearray`." -msgstr "" +msgstr "可參考 :ref:`binaryseq` 和 :ref:`typebytearray`。" #: ../../builtins/functions.rst:222 msgid "" @@ -590,19 +649,22 @@ msgid "" "class:`bytearray` -- it has the same non-mutating methods and the same " "indexing and slicing behavior." msgstr "" +"回傳一個新的 \"bytes\" 物件,會是一個元素是範圍為 ``0 <= x < 256`` 整數的不可" +"變序列。:class:`bytes` 是 :class:`bytearray` 的不可變版本 — 它的同樣具備不改" +"變物件的 method,也有相同的索引和切片操作。" #: ../../builtins/functions.rst:227 msgid "" "Accordingly, constructor arguments are interpreted as for :func:`bytearray`." -msgstr "" +msgstr "因此,建構函式的引數和 :func:`bytearray` 相同。" #: ../../builtins/functions.rst:229 msgid "Bytes objects can also be created with literals, see :ref:`strings`." -msgstr "" +msgstr "Bytes 物件還可以用文字建立,參見 :ref:`strings`。" #: ../../builtins/functions.rst:231 msgid "See also :ref:`binaryseq`, :ref:`typebytes`, and :ref:`bytes-methods`." -msgstr "" +msgstr "可參考 :ref:`binaryseq`、:ref:`typebytes` 和 :ref:`bytes-methods`。" #: ../../builtins/functions.rst:236 msgid "" @@ -612,12 +674,16 @@ msgid "" "that classes are callable (calling a class returns a new instance); " "instances are callable if their class has a :meth:`~object.__call__` method." msgstr "" +"如果引數 *object* 是可呼叫的,回傳 :const:`True`,否則回傳 :const:`False`。如" +"果回傳 ``True``,呼叫仍可能會失敗;但如果回傳 ``False``,則呼叫 *object* 肯定" +"會失敗。注意 class 是可呼叫的(呼叫 class 會回傳一個新的實例);如果實例的 " +"class 有定義 :meth:`~object.__call__` method,則它是可呼叫的。" #: ../../builtins/functions.rst:242 msgid "" "This function was first removed in Python 3.0 and then brought back in " "Python 3.2." -msgstr "" +msgstr "這個函式一開始在 Python 3.0 被移除,但在 Python 3.2 又被重新加入。" #: ../../builtins/functions.rst:249 msgid "" @@ -625,16 +691,20 @@ msgid "" "point. For example, ``chr(97)`` returns the string ``'a'``, while " "``chr(8364)`` returns the string ``'€'``. This is the inverse of :func:`ord`." msgstr "" +"回傳代表有特定 Unicode 編碼位置字元的字串。例如,``chr(97)`` 回傳字串 " +"``'a'``,而 ``chr(8364)`` 回傳字串 ``'€'``。這是 :func:`ord` 的逆函式。" #: ../../builtins/functions.rst:253 msgid "" "The valid range for the argument is from 0 through 1,114,111 (0x10FFFF in " "base 16). :exc:`ValueError` will be raised if it is outside that range." msgstr "" +"引數的有效範圍是 0 到 1,114,111(16 進制表示為 0x10FFFF)。如果它超過這個範" +"圍,會引發 :exc:`ValueError`。" #: ../../builtins/functions.rst:259 msgid "Transform a method into a class method." -msgstr "" +msgstr "把一個 method 封裝成 class method(類別方法)。" #: ../../builtins/functions.rst:261 msgid "" @@ -642,6 +712,8 @@ msgid "" "an instance method receives the instance. To declare a class method, use " "this idiom::" msgstr "" +"一個 class method 把自己的 class 作為第一個引數,就像一個實例 method 把實例自" +"己作為第一個引數。請用以下慣例來宣告 class method: ::" #: ../../builtins/functions.rst:265 msgid "" @@ -649,12 +721,17 @@ msgid "" " @classmethod\n" " def f(cls, arg1, arg2): ..." msgstr "" +"class C:\n" +" @classmethod\n" +" def f(cls, arg1, arg2): ..." #: ../../builtins/functions.rst:269 msgid "" "The ``@classmethod`` form is a function :term:`decorator` -- see :ref:" "`function` for details." msgstr "" +"``@classmethod`` 語法是一個函式 :term:`decorator` — 參見 :ref:`function` 中關" +"於函式定義的詳細介紹。" #: ../../builtins/functions.rst:272 msgid "" @@ -663,6 +740,9 @@ msgid "" "class. If a class method is called for a derived class, the derived class " "object is passed as the implied first argument." msgstr "" +"一個 class method 可以在 class(如 ``C.f()``)或實例(如 ``C().f()``)上呼" +"叫。實例除了它的 class 資訊,其他都會被忽略。如果一個 class method 在 " +"subclass 上呼叫,subclass 會作為第一個引數傳入。" #: ../../builtins/functions.rst:277 msgid "" @@ -670,12 +750,17 @@ msgid "" "those, see :func:`staticmethod` in this section. For more information on " "class methods, see :ref:`types`." msgstr "" +"Class method 和 C++ 與 Java 的 static method 是有區別的。如果你想瞭解 static " +"method,請看本節的 :func:`staticmethod`。關於 class method 的更多資訊,請參考" +"\\ :ref:`types`。" #: ../../builtins/functions.rst:281 msgid "" "Class methods can now wrap other :term:`descriptors ` such as :" "func:`property`." msgstr "" +"Class methods 現在可以包裝其他\\ :term:`描述器 `,例如 :func:" +"`property`" #: ../../builtins/functions.rst:285 msgid "" @@ -684,12 +769,18 @@ msgid "" "attr:`~function.__doc__` and :attr:`~function.__annotations__`) and have a " "new ``__wrapped__`` attribute." msgstr "" +"Class method 現在繼承了 method 屬性(:attr:`~function.__module__`、:attr:" +"`~function.__name__`、:attr:`~function.__qualname__`、:attr:`~function." +"__doc__` 和 :attr:`~function.__annotations__`),並擁有一個新的 " +"``__wrapped__`` 屬性。" #: ../../builtins/functions.rst:292 msgid "" "Class methods can no longer wrap other :term:`descriptors ` such " "as :func:`property`." msgstr "" +"Class methods 不能再包裝其他的\\ :term:`描述器 `,例如 :func:" +"`property`。" #: ../../builtins/functions.rst:299 msgid "" @@ -698,6 +789,9 @@ msgid "" "string, a byte string, or an AST object. Refer to the :mod:`ast` module " "documentation for information on how to work with AST objects." msgstr "" +"將 *source* 編譯成程式碼或 AST 物件。程式碼物件可以被 :func:`exec` 或 :func:" +"`eval` 執行。*source* 可以是一般的字串、bytes 字串、或者 AST 物件。參見 :mod:" +"`ast` module(模組)的說明文件瞭解如何使用 AST 物件。" #: ../../builtins/functions.rst:304 msgid "" @@ -705,6 +799,8 @@ msgid "" "pass some recognizable value if it wasn't read from a file (``''`` " "is commonly used)." msgstr "" +"*filename* 引數必須是程式碼的檔名;如果程式碼不是從檔案中讀取,可以傳入一些可" +"辨識的值(經常會使用 ``''`` 來替代)。" #: ../../builtins/functions.rst:308 msgid "" @@ -714,6 +810,10 @@ msgid "" "single interactive statement (in the latter case, expression statements that " "evaluate to something other than ``None`` will be printed)." msgstr "" +"*mode* 引數指定了編譯程式碼時必須用的模式。如果 *source* 是一系列的陳述式,可" +"以是 ``'exec'``;如果是單一運算式,可以是 ``'eval'``;如果是單個互動式陳述" +"式,可以是 ``'single'``\\ (在最後一種情況下,如果運算式執行結果不是 " +"``None`` 則會被印出來)。" #: ../../builtins/functions.rst:314 msgid "" @@ -728,6 +828,13 @@ msgid "" "*flags* argument is it -- the flags (future features and compiler options) " "in the surrounding code are ignored." msgstr "" +"可選引數 *flags* 和 *dont_inherit* 控制啟用哪個\\ :ref:`編譯器選項 `\\ 以及允許哪個\\ :ref:`未來功能 `。如果兩者都不存在" +"(或兩者都為零),則會呼叫與 :func:`compile` 相同旗標的程式碼來編譯。如果給" +"定 *flags* 引數而未給定 *dont_inherit*\\ (或為零)則無論如何都會使用由 " +"*flags* 引數所指定的編譯器選項和未來陳述式。如果 *dont_inherit* 是一個非零整" +"數,則使用 *flags* 引數 -- 周圍程式碼中的旗標(未來功能和編譯器選項)將被忽" +"略。" #: ../../builtins/functions.rst:325 msgid "" @@ -738,6 +845,11 @@ msgid "" "instance in the :mod:`__future__` module. :ref:`Compiler flags ` can be found in :mod:`ast` module, with ``PyCF_`` prefix." msgstr "" +"編譯器選項和 future 陳述式使用 bits 來表示,可以一起被位元操作 OR 來表示複數" +"個選項。需要被具體定義特徵的位元域可以透過 :mod:`__future__` module 中 :" +"class:`~__future__._Feature` 實例中的 :attr:`~__future__._Feature." +"compiler_flag` 屬性來獲得。:ref:`編譯器旗標 `\\ 可以在 :" +"mod:`ast` module 中搜尋有 ``PyCF_`` 前綴的名稱。" #: ../../builtins/functions.rst:333 msgid "" @@ -747,18 +859,23 @@ msgid "" "optimization; ``__debug__`` is true), ``1`` (asserts are removed, " "``__debug__`` is false) or ``2`` (docstrings are removed too)." msgstr "" +"引數 *optimize* 用來指定編譯器的最佳化級別;預設值 ``-1`` 選擇與直譯器的 :" +"option:`-O` 選項相同的最佳化級別。其他級別為 ``0``\\ (沒有最佳化;\\ " +"``__debug__`` 為真值)、``1``\\ (assert 被刪除,``__debug__`` 為假值)或 " +"``2``\\ (說明字串 (docstring) 也被刪除)。" #: ../../builtins/functions.rst:339 msgid "" "This function raises :exc:`SyntaxError` or :exc:`ValueError` if the compiled " "source is invalid." msgstr "" +"如果編譯的原始碼無效,此函式會引發 :exc:`SyntaxError` 或 :exc:`ValueError`。" #: ../../builtins/functions.rst:342 msgid "" "If you want to parse Python code into its AST representation, see :func:`ast." "parse`." -msgstr "" +msgstr "如果你想解析 Python 程式碼為 AST 運算式,請參閱 :func:`ast.parse`。" #: ../../builtins/functions.rst:345 ../../builtins/functions.rst:347 msgid "" @@ -766,6 +883,8 @@ msgid "" "``source`` and ``filename``. This event may also be raised by implicit " "compilation." msgstr "" +"引發一個附帶引數 ``source``、``filename`` 的\\ :ref:`稽核事件 ` " +"``compile``。此事件也可能由隱式編譯 (implicit compilation) 所引發。" #: ../../builtins/functions.rst:353 msgid "" @@ -774,6 +893,8 @@ msgid "" "to facilitate detection of incomplete and complete statements in the :mod:" "`code` module." msgstr "" +"在 ``'single'`` 或 ``'eval'`` 模式編譯多行程式碼時,輸入必須以至少一個換行符" +"結尾。這使 :mod:`code` module 更容易檢測陳述式的完整性。" #: ../../builtins/functions.rst:360 msgid "" @@ -781,35 +902,41 @@ msgid "" "complex string when compiling to an AST object due to stack depth " "limitations in Python's AST compiler." msgstr "" +"如果編譯足夠大或者足夠複雜的字串成 AST 物件時,Python 直譯器會因為 Python " +"AST 編譯器的 stack 深度限制而崩潰。" #: ../../builtins/functions.rst:364 msgid "" "Allowed use of Windows and Mac newlines. Also, input in ``'exec'`` mode " "does not have to end in a newline anymore. Added the *optimize* parameter." msgstr "" +"允許使用 Windows 和 Mac 的換行符號。此外,在 ``'exec'`` 模式不需要以換行符號" +"結尾。增加了 *optimize* 參數。" #: ../../builtins/functions.rst:368 msgid "" "Previously, :exc:`TypeError` was raised when null bytes were encountered in " "*source*." -msgstr "" +msgstr "在之前的版本,*source* 中包含 null bytes 會引發 :exc:`TypeError`。" #: ../../builtins/functions.rst:372 msgid "" "``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` can now be passed in flags to enable " "support for top-level ``await``, ``async for``, and ``async with``." msgstr "" +"``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` 現在可以傳遞旗標以啟用對頂層 ``await``、" +"``async for`` 和 ``async with`` 的支援。" #: ../../builtins/functions.rst:381 msgid "" "Convert a single string or number to a complex number, or create a complex " "number from real and imaginary parts." -msgstr "" +msgstr "將單一字串或數字轉換為複數,或從實部和虛部建立複數。" #: ../../builtins/functions.rst:384 ../../builtins/functions.rst:764 #: ../../builtins/functions.rst:1012 msgid "Examples:" -msgstr "" +msgstr "例如: ::" #: ../../builtins/functions.rst:386 msgid "" @@ -830,6 +957,22 @@ msgid "" ">>> complex(-1.23, 4.5)\n" "(-1.23+4.5j)" msgstr "" +">>> complex('+1.23')\n" +"(1.23+0j)\n" +">>> complex('-4.5j')\n" +"-4.5j\n" +">>> complex('-1.23+4.5j')\n" +"(-1.23+4.5j)\n" +">>> complex('\\t( -1.23+4.5J )\\n')\n" +"(-1.23+4.5j)\n" +">>> complex('-Infinity+NaNj')\n" +"(-inf+nanj)\n" +">>> complex(1.23)\n" +"(1.23+0j)\n" +">>> complex(imag=-4.5)\n" +"-4.5j\n" +">>> complex(-1.23, 4.5)\n" +"(-1.23+4.5j)" #: ../../builtins/functions.rst:405 msgid "" @@ -845,6 +988,14 @@ msgid "" "token:`~float:complexvalue` production rule in the following grammar, after " "parentheses and leading and trailing whitespace characters are removed:" msgstr "" +"如果引數是字串,它必須包含實數部分(格式與 :func:`float` 相同)或虛數部分(格" +"式相同,但後綴為 ``'j'`` 或 ``'J'``),或同時包含實數部分和虛數部分(在這種情" +"況下,虛數部分的符號是必須的)。字串可以選擇以空白和圓括號 ``'('`` 和 " +"``')'`` 包圍,這些都會被忽略。字串在 ``'+'``、``'-'``、``'j'`` 或 ``'J'`` 後" +"綴和十進位數字之間不能包含空白。例如,``complex('1+2j')`` 沒有問題,但 " +"``complex('1 + 2j')`` 會引發 :exc:`ValueError`。更精確地說,輸入必須符合以下" +"文法中的 :token:`~float:complexvalue` 產生規則,在去除括號和前後空白字元之" +"後:" #: ../../builtins/functions.rst:424 msgid "" @@ -855,6 +1006,11 @@ msgid "" "If :meth:`!__float__` is not defined then it falls back to :meth:`~object." "__index__`." msgstr "" +"如果引數是一個數字,則建構函式會像 :class:`int` 和 :class:`float` 一樣進行數" +"值轉換。對於一個普通的 Python 物件 ``x``,``complex(x)`` 會委派給 ``x." +"__complex__()``。如果 :meth:`~object.__complex__` 未定義,則會回退 (fall " +"back) 到 :meth:`~object.__float__`。如果 :meth:`!__float__` 未定義,則會再回" +"退到 :meth:`~object.__index__`。" #: ../../builtins/functions.rst:433 msgid "" @@ -866,37 +1022,45 @@ msgid "" "imaginary component ``real.imag+imag.real``. If one of arguments is a real " "number, only its real component is used in the above expressions." msgstr "" +"如果提供兩個引數或使用關鍵字引數,每個引數可以是任何數值型別(包括複數)。如" +"果兩個引數都是實數,則回傳一個有實數分量 *real* 和虛數分量 *imag* 的複數。如" +"果兩個引數都是複數,則回傳一個包含實數分量 ``real.real-imag.imag`` 和虛數分" +"量 ``real.imag+imag.real`` 的複數。如果其中一個引數是實數,則在上述運算式中只" +"使用其實數分量。" #: ../../builtins/functions.rst:443 msgid "" "See also :meth:`complex.from_number` which only accepts a single numeric " "argument." -msgstr "" +msgstr "也請參閱 :meth:`complex.from_number`,它只接受單一數值引數。" #: ../../builtins/functions.rst:445 msgid "If all arguments are omitted, returns ``0j``." -msgstr "" +msgstr "如果省略所有引數,則回傳 ``0j``。" #: ../../builtins/functions.rst:447 msgid "The complex type is described in :ref:`typesnumeric`." -msgstr "" +msgstr "複數型別在 :ref:`typesnumeric` 中有相關描述。" #: ../../builtins/functions.rst:449 ../../builtins/functions.rst:818 #: ../../builtins/functions.rst:1060 msgid "Grouping digits with underscores as in code literals is allowed." -msgstr "" +msgstr "可以使用底線將程式碼文字中的數字進行分組。" #: ../../builtins/functions.rst:452 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` and :" "meth:`~object.__float__` are not defined." msgstr "" +"如果 :meth:`~object.__complex__` 和 :meth:`~object.__float__` 未定義,則會回" +"退到 :meth:`~object.__index__`。" #: ../../builtins/functions.rst:456 msgid "" "Passing a complex number as the *real* or *imag* argument is now deprecated; " "it should only be passed as a single positional argument." msgstr "" +"傳遞複數作為 *real* 或 *imag* 引數現已被棄用;它只應作為單一位置引數傳遞。" #: ../../builtins/functions.rst:463 msgid "" @@ -906,18 +1070,26 @@ msgid "" "example, ``delattr(x, 'foobar')`` is equivalent to ``del x.foobar``. *name* " "need not be a Python identifier (see :func:`setattr`)." msgstr "" +"這是 :func:`setattr` 相關的函式。引數是一個物件和一個字串,該字串必須是物件中" +"某個屬性名稱。如果物件允許,該函式將刪除指定的屬性。例如 ``delattr(x, " +"'foobar')`` 等價於 ``del x.foobar``。*name* 不必是個 Python 識別符 " +"(identifier)(請見 :func:`setattr`)。" #: ../../builtins/functions.rst:476 msgid "" "Create a new dictionary. The :class:`dict` object is the dictionary class. " "See also :ref:`typesmapping` for documentation about this class." msgstr "" +"建立一個新的 dictionary(字典)。:class:`dict` 物件是一個 dictionary class。" +"亦請參閱 :ref:`typesmapping` 來瞭解這個 class。" #: ../../builtins/functions.rst:479 msgid "" "For other containers see the built-in :class:`list`, :class:`set`, and :" "class:`tuple` classes, as well as the :mod:`collections` module." msgstr "" +"其他容器型別,請參見內建的 :class:`list`、:class:`set` 和 :class:`tuple` " +"class,以及 :mod:`collections` module。" #: ../../builtins/functions.rst:486 msgid "" @@ -925,6 +1097,8 @@ msgid "" "With an argument, attempt to return a list of valid attributes for that " "object." msgstr "" +"如果沒有引數,則回傳目前區域作用域 (local scope) 中的名稱列表。如果有引數,它" +"會嘗試回傳該物件的有效屬性列表。" #: ../../builtins/functions.rst:489 msgid "" @@ -934,6 +1108,10 @@ msgid "" "__getattribute__` function to customize the way :func:`dir` reports their " "attributes." msgstr "" +"如果物件有一個名為 :meth:`~object.__dir__` 的 method,那麼該 method 將被呼" +"叫,並且必須回傳一個屬性列表。這允許實現自訂 :func:`~object.__getattr__` 或 :" +"func:`~object.__getattribute__` 函式的物件能夠自訂 :func:`dir` 來報告它們的屬" +"性。" #: ../../builtins/functions.rst:496 msgid "" @@ -943,6 +1121,9 @@ msgid "" "necessarily complete and may be inaccurate when the object has a custom :" "func:`~object.__getattr__`." msgstr "" +"如果物件不提供 :meth:`~object.__dir__`,這個函式會嘗試從物件已定義的 :attr:" +"`~object.__dict__` 屬性和型別物件收集資訊。結果列表並不總是完整的,如果物件有" +"自訂 :func:`~object.__getattr__`,那結果可能不準確。" #: ../../builtins/functions.rst:502 msgid "" @@ -950,18 +1131,22 @@ msgid "" "of objects, as it attempts to produce the most relevant, rather than " "complete, information:" msgstr "" +"預設的 :func:`dir` 機制對不同型別的物件有不同行為,它會試圖回傳最相關而非最完" +"整的資訊:" #: ../../builtins/functions.rst:506 msgid "" "If the object is a module object, the list contains the names of the " "module's attributes." -msgstr "" +msgstr "如果物件是 module 物件,則列表包含 module 的屬性名稱。" #: ../../builtins/functions.rst:509 msgid "" "If the object is a type or class object, the list contains the names of its " "attributes, and recursively of the attributes of its bases." msgstr "" +"如果物件是型別或 class 物件,則列表包含它們的屬性名稱,並且遞迴查詢其基礎的所" +"有屬性。" #: ../../builtins/functions.rst:512 msgid "" @@ -969,10 +1154,12 @@ msgid "" "its class's attributes, and recursively of the attributes of its class's " "base classes." msgstr "" +"否則,包含物件的屬性名稱列表、它的 class 屬性名稱,並且遞迴查詢它的 class 的" +"所有基礎 class 的屬性。" #: ../../builtins/functions.rst:516 msgid "The resulting list is sorted alphabetically. For example:" -msgstr "" +msgstr "回傳的列表按字母表排序,例如:" #: ../../builtins/functions.rst:536 msgid "" @@ -982,6 +1169,10 @@ msgid "" "its detailed behavior may change across releases. For example, metaclass " "attributes are not in the result list when the argument is a class." msgstr "" +"因為 :func:`dir` 主要是為了便於在互動式提示字元時使用,所以它會試圖回傳人們感" +"興趣的名稱集合,而不是試圖保證結果的嚴格性或一致性,它具體的行為也可能在不同" +"版本之間改變。例如,當引數是一個 class 時,metaclass 的屬性不包含在結果列表" +"中。" #: ../../builtins/functions.rst:546 msgid "" @@ -994,6 +1185,12 @@ msgid "" "is very close to *a*, if ``a % b`` is non-zero it has the same sign as *b*, " "and ``0 <= abs(a % b) < abs(b)``." msgstr "" +"它將兩個(非複數)數字作為引數,並在執行整數除法時回傳一對商和餘數。對於混合" +"運算元型別,適用二進位算術運算子的規則。對於整數,運算結果和 ``(a // b, a % " +"b)`` 一致。對於浮點數,運算結果是 ``(q, a % b)``,*q* 通常是 ``math." +"floor(a / b)`` 但可能會比 1 小。在任何情況下,``q * b + a % b`` 和 *a* 基本相" +"等,如果 ``a % b`` 非零,則它的符號和 *b* 一樣,且 ``0 <= abs(a % b) < " +"abs(b)``。" #: ../../builtins/functions.rst:558 msgid "" @@ -1003,10 +1200,14 @@ msgid "" "returns a tuple containing a count (from *start* which defaults to 0) and " "the values obtained from iterating over *iterable*." msgstr "" +"回傳一個列舉 (enumerate) 物件。*iterable* 必須是一個序列、:term:`iterator` 或" +"其他支援疊代的物件。:func:`enumerate` 回傳之 iterator 的 :meth:`~iterator." +"__next__` method 回傳一個 tuple(元組),裡面包含一個計數值(從 *start* 開" +"始,預設為 0)和透過疊代 *iterable* 獲得的值。" #: ../../builtins/functions.rst:570 msgid "Equivalent to::" -msgstr "" +msgstr "等價於: ::" #: ../../builtins/functions.rst:572 msgid "" @@ -1016,44 +1217,50 @@ msgid "" " yield n, elem\n" " n += 1" msgstr "" +"def enumerate(iterable, start=0):\n" +" n = start\n" +" for elem in iterable:\n" +" yield n, elem\n" +" n += 1" #: ../../builtins/functions.rst:0 msgid "Parameters" -msgstr "" +msgstr "參數" #: ../../builtins/functions.rst:582 msgid "A Python expression." -msgstr "" +msgstr "一個 Python 運算式。" #: ../../builtins/functions.rst:586 msgid "The global namespace (default: ``None``)." -msgstr "" +msgstr "全域命名空間(預設值:``None``)。" #: ../../builtins/functions.rst:590 msgid "The local namespace (default: ``None``)." -msgstr "" +msgstr "區域命名空間(預設:``None``)。" #: ../../builtins/functions.rst:0 msgid "Returns" -msgstr "" +msgstr "回傳值" #: ../../builtins/functions.rst:594 msgid "The result of the evaluated expression." -msgstr "" +msgstr "被求值的運算式之結果。" #: ../../builtins/functions.rst:0 msgid "raises" -msgstr "" +msgstr "引發" #: ../../builtins/functions.rst:595 msgid "Syntax errors are reported as exceptions." -msgstr "" +msgstr "語法錯誤會報告為例外。" #: ../../builtins/functions.rst:599 ../../builtins/functions.rst:665 msgid "" "This function executes arbitrary code. Calling it with untrusted user-" "supplied input will lead to security vulnerabilities." msgstr "" +"此函式會執行任意程式碼。以不受信任的使用者提供的輸入來呼叫它將導致安全漏洞。" #: ../../builtins/functions.rst:602 msgid "" @@ -1073,10 +1280,21 @@ msgid "" "referenced in the scope that is calling :func:`eval` (e.g. via a :keyword:" "`nonlocal` statement)." msgstr "" +"*source* 引數會被視為一條 Python 運算式(技術上而言,是\\ :ref:`運算式串列 " +"`\\ )來剖析及求值,而 *globals* 和 *locals* 對映分別用作全域和區" +"域命名空間。如果 *globals* dictionary 存在但缺少 ``__builtins__`` 的鍵值,那" +"*source* 被剖析之前,將為該鍵插入對內建 :mod:`builtins` module dictionary 的" +"引用。覆寫 ``__builtins__`` 可以用來限制或更改可用的名稱,但這\\ **不是**\\ " +"一種安全機制:被執行的程式碼仍然可以存取所有內建名稱。如果 *locals* 對映被省" +"略,那它的預設值是 *globals* dictionary。如果兩個對映都被省略,則以在 :func:" +"`eval` 被呼叫的環境中的 *globals* 和 *locals* 執行原始碼。請注意,*eval()* 在" +"封閉 (enclosing) 環境中無法存取\\ :term:`巢狀作用域 ` (non-" +"locals),除非呼叫 :func:`eval` 的作用域已經有參照它們(例如透過:keyword:" +"`nonlocal` 陳述式)。" #: ../../builtins/functions.rst:620 msgid "Example:" -msgstr "" +msgstr "範例:" #: ../../builtins/functions.rst:629 msgid "" @@ -1085,6 +1303,9 @@ msgid "" "of a string. If the code object has been compiled with ``'exec'`` as the " "*mode* argument, :func:`eval`\\'s return value will be ``None``." msgstr "" +"這個函式也可以用來執行任意程式碼物件(如被 :func:`compile` 建立的那些)。這種" +"情況下,傳入的引數是程式碼物件而不是字串。如果編譯該物件時的 *mode* 引數是 " +"``'exec'``,那麼 :func:`eval` 回傳值為 ``None``。" #: ../../builtins/functions.rst:634 msgid "" @@ -1093,18 +1314,23 @@ msgid "" "current global and local dictionary, respectively, which may be useful to " "pass around for use by :func:`eval` or :func:`exec`." msgstr "" +"提示::func:`exec` 函式支援動態執行陳述式。:func:`globals` 和 :func:`locals` " +"函式分別回傳目前的全域性和局部性 dictionary,它們對於將引數傳遞給 :func:" +"`eval` 或 :func:`exec` 可能會方便許多。" #: ../../builtins/functions.rst:639 msgid "" "If the given source is a string, then leading and trailing spaces and tabs " "are stripped." -msgstr "" +msgstr "如果給定來源是一個字串,那麼其前後的空格和定位字元會被移除。" #: ../../builtins/functions.rst:642 msgid "" "See :func:`ast.literal_eval` for a function to evaluate strings with " "expressions containing only literals." msgstr "" +"另外可以參閱 :func:`ast.literal_eval`,該函式可用來執行僅包含文字的運算式字" +"串。" #: ../../builtins/functions.rst:645 ../../builtins/functions.rst:647 #: ../../builtins/functions.rst:708 ../../builtins/functions.rst:710 @@ -1112,16 +1338,18 @@ msgid "" "Raises an :ref:`auditing event ` ``exec`` with the code object as " "the argument. Code compilation events may also be raised." msgstr "" +"引發一個附帶程式碼物件為引數的\\ :ref:`稽核事件 ` ``exec``。也可能" +"會引發程式碼編譯事件。" #: ../../builtins/functions.rst:652 ../../builtins/functions.rst:730 msgid "The *globals* and *locals* arguments can now be passed as keywords." -msgstr "" +msgstr "*globals* 和 *locals* 引數現在可以作為關鍵字傳遞。" #: ../../builtins/functions.rst:656 ../../builtins/functions.rst:734 msgid "" "The semantics of the default *locals* namespace have been adjusted as " "described for the :func:`locals` builtin." -msgstr "" +msgstr "如 :func:`locals` 內建物件所述,已調整預設 *locals* 命名空間的語意。" #: ../../builtins/functions.rst:668 msgid "" @@ -1135,6 +1363,13 @@ msgid "" "not be used outside of function definitions even within the context of code " "passed to the :func:`exec` function. The return value is ``None``." msgstr "" +"這個函式支援動態執行 Python 程式碼。*source* 必須是字串或者程式碼物件。如果是" +"字串,那麼該字串將被剖析為一系列 Python 陳述式並執行(除非發生語法錯誤)。" +"[#]_ 如果是程式碼物件,它將被直接執行。無論哪種情況,被執行的程式碼都需要和檔" +"案輸入一樣是有效的(可參閱語言參考手冊中關於\\ :ref:`file-input`\\ 的章節)。" +"請注意,即使在傳遞給 :func:`exec` 函式的程式碼的上下文中,:keyword:" +"`nonlocal`、:keyword:`yield` 和 :keyword:`return` 陳述式也不能在函式之外使" +"用。該函式回傳值是 ``None``。" #: ../../builtins/functions.rst:679 msgid "" @@ -1146,6 +1381,11 @@ msgid "" "any mapping object. Remember that at the module level, globals and locals " "are the same dictionary." msgstr "" +"無論哪種情況,如果省略了選擇性的部分,程式碼將在目前作用域內執行。如果只提供" +"了 *globals* 引數,就必須是 dictionary 型別(且不能是 dictionary 的子類別)," +"而且會被用作全域和區域變數。如果同時提供了 *globals* 和 *locals*,它們分別被" +"用作全域和區域變數。如果提供了 *locals*,則它可以是任何對映物件。請記住在 " +"module 層級中全域和區域變數是相同的 dictionary。" #: ../../builtins/functions.rst:689 msgid "" @@ -1155,6 +1395,9 @@ msgid "" "access variables assigned at the top level (as the \"top level\" variables " "are treated as class variables in a class definition)." msgstr "" +"當 ``exec`` 得到兩個獨立的物件作為 *globals* 和 *locals*,程式碼會被執行,就" +"像它被嵌入在類別定義中一樣。這表示在執行的程式碼中定義的函式和類別將無法存取" +"在頂層指定的變數(因為在類別定義中,「頂層」變數被視為類別變數)。" #: ../../builtins/functions.rst:695 msgid "" @@ -1164,6 +1407,10 @@ msgid "" "used to restrict or change the available names, but this is **not** a " "security mechanism: the executed code can still access all builtins." msgstr "" +"如果 *globals* dictionary 不包含 ``__builtins__`` 鍵值,則將為該鍵插入對內" +"建 :mod:`builtins` module dictionary 的引用。覆寫 ``__builtins__`` 可以用來限" +"制或更改可用的名稱,但這\\ **不是**\\ 一種安全機制:被執行的程式碼仍然可以存" +"取所有內建名稱。" #: ../../builtins/functions.rst:702 msgid "" @@ -1172,6 +1419,10 @@ msgid "" "variables `. The length of the tuple must exactly match " "the length of the code object's :attr:`~codeobject.co_freevars` attribute." msgstr "" +"*closure* 引數會指定一個閉包 (closure) — 它是一個 cellvar(格變數)的 tuple。" +"只有在 *object* 是一個含有\\ :term:`自由(閉包)變數 (free (closure) " +"variables) ` 的程式碼物件時,它才有效。Tuple 的長度必須與程" +"式碼物件的 :attr:`~codeobject.co_freevars` 屬性完全匹配。" #: ../../builtins/functions.rst:715 msgid "" @@ -1179,6 +1430,8 @@ msgid "" "global and local namespace, respectively, which may be useful to pass around " "for use as the second and third argument to :func:`exec`." msgstr "" +"內建 :func:`globals` 和 :func:`locals` 函式各自回傳目前的全域和區域命名空間," +"因此可以將它們傳遞給 :func:`exec` 的第二個和第三個引數以供後續使用。" #: ../../builtins/functions.rst:721 msgid "" @@ -1186,10 +1439,13 @@ msgid "" "Pass an explicit *locals* dictionary if you need to see effects of the code " "on *locals* after function :func:`exec` returns." msgstr "" +"預設情況下,*locals* 的行為如下面 :func:`locals` 函式描述的一樣。如果你想在 :" +"func:`exec` 函式回傳時知道程式碼對 *locals* 的變動,請明確地傳遞 *locals* " +"dictionary 。" #: ../../builtins/functions.rst:725 msgid "Added the *closure* parameter." -msgstr "" +msgstr "增加了 *closure* 參數。" #: ../../builtins/functions.rst:740 msgid "" @@ -1198,6 +1454,10 @@ msgid "" "iteration, or an iterator. If *function* is ``None``, the identity function " "is assumed, that is, all elements of *iterable* that are false are removed." msgstr "" +"用 *iterable* 中函式 *function* 為 True 的那些元素,構建一個新的 iterator。" +"*iterable* 可以是一個序列、一個支援疊代的容器、或一個 iterator。如果 " +"*function* 是 ``None``,則會假設它是一個識別性函式,即 *iterable* 中所有假值" +"元素會被移除。" #: ../../builtins/functions.rst:746 msgid "" @@ -1206,16 +1466,21 @@ msgid "" "not ``None`` and ``(item for item in iterable if item)`` if function is " "``None``." msgstr "" +"請注意,``filter(function, iterable)`` 相當於一個生成器運算式,當 function 不" +"是 ``None`` 的時候為 ``(item for item in iterable if function(item))``;" +"function 是 ``None`` 的時候為 ``(item for item in iterable if item)``。" #: ../../builtins/functions.rst:751 msgid "" "See :func:`itertools.filterfalse` for the complementary function that " "returns elements of *iterable* for which *function* is false." msgstr "" +"請參閱 :func:`itertools.filterfalse`,只有 *function* 為 false 時才選取 " +"*iterable* 中元素的互補函式。" #: ../../builtins/functions.rst:762 msgid "Return a floating-point number constructed from a number or a string." -msgstr "" +msgstr "回傳從數字或字串生成的浮點數。" #: ../../builtins/functions.rst:766 msgid "" @@ -1230,6 +1495,16 @@ msgid "" ">>> float('-Infinity')\n" "-inf" msgstr "" +">>> float('+1.23')\n" +"1.23\n" +">>> float(' -12345\\n')\n" +"-12345.0\n" +">>> float('1e-003')\n" +"0.001\n" +">>> float('+1E6')\n" +"1000000.0\n" +">>> float('-Infinity')\n" +"-inf" #: ../../builtins/functions.rst:779 msgid "" @@ -1241,12 +1516,18 @@ msgid "" "conform to the :token:`~float:floatvalue` production rule in the following " "grammar, after leading and trailing whitespace characters are removed:" msgstr "" +"如果引數是字串,則它必須是包含十進位制數字的字串,字串前面可以有符號,之前也" +"可以有空格。選擇性的符號有 ``'+'`` 和 ``'-'``;``'+'`` 對建立的值沒有影響。引" +"數也可以是 NaN(非數字)或正負無窮大的字串。確切地說,除去首尾的空格後,輸入" +"必須遵循以下語法中 :token:`~float:floatvalue` 的生成規則:" #: ../../builtins/functions.rst:800 msgid "" "Case is not significant, so, for example, \"inf\", \"Inf\", \"INFINITY\", " "and \"iNfINity\" are all acceptable spellings for positive infinity." msgstr "" +"字母大小寫不影響,例如,\"inf\"、\"Inf\"、\"INFINITY\"、\"iNfINity\" 都可以表" +"示正無窮大。" #: ../../builtins/functions.rst:803 msgid "" @@ -1255,6 +1536,8 @@ msgid "" "precision) is returned. If the argument is outside the range of a Python " "float, an :exc:`OverflowError` will be raised." msgstr "" +"否則,如果引數是整數或浮點數,則回傳具有相同值(在 Python 浮點精度範圍內)的" +"浮點數。如果引數在 Python 浮點精度範圍外,則會引發 :exc:`OverflowError`。" #: ../../builtins/functions.rst:808 msgid "" @@ -1262,25 +1545,28 @@ msgid "" "__float__()``. If :meth:`~object.__float__` is not defined then it falls " "back to :meth:`~object.__index__`." msgstr "" +"對於一般的 Python 物件 ``x``,``float(x)`` 會委派給 ``x.__float__()``。如果未" +"定義 :meth:`~object.__float__` 則會回退到 :meth:`~object.__index__`。" #: ../../builtins/functions.rst:812 msgid "" "See also :meth:`float.from_number` which only accepts a numeric argument." -msgstr "" +msgstr "也請參閱 :meth:`float.from_number`,它只接受一個數值引數。" #: ../../builtins/functions.rst:814 msgid "If no argument is given, ``0.0`` is returned." -msgstr "" +msgstr "如果沒有引數,則回傳 ``0.0``。" #: ../../builtins/functions.rst:816 msgid "The float type is described in :ref:`typesnumeric`." -msgstr "" +msgstr ":ref:`typesnumeric` 描述了浮點數型別。" #: ../../builtins/functions.rst:824 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__float__` is not " "defined." msgstr "" +"如果 :meth:`~object.__float__` 未定義,則會回退到 :meth:`~object.__index__`。" #: ../../builtins/functions.rst:834 msgid "" @@ -1289,12 +1575,17 @@ msgid "" "of the *value* argument; however, there is a standard formatting syntax that " "is used by most built-in types: :ref:`formatspec`." msgstr "" +"將 *value* 轉換為 *format_spec* 控制的 \"格式化\" 表示。*format_spec* 的解釋" +"取決於 *value* 引數的型別,但是大多數內建型別使用標準格式化語法::ref:" +"`formatspec`。" #: ../../builtins/functions.rst:839 msgid "" "The default *format_spec* is an empty string which usually gives the same " "effect as calling :func:`str(value) `." msgstr "" +"預設的 *format_spec* 是一個空字串,它通常和呼叫 :func:`str(value) ` 的效" +"果相同。" #: ../../builtins/functions.rst:842 msgid "" @@ -1305,12 +1596,18 @@ msgid "" "and the *format_spec* is non-empty, or if either the *format_spec* or the " "return value are not strings." msgstr "" +"呼叫 ``format(value, format_spec)`` 會轉換成 ``type(value).__format__(value, " +"format_spec)``,當搜尋 value 的 :meth:`~object.__format__` method 時,會忽略" +"實例中的字典。如果搜尋到 :mod:`object` 這個 method 但 *format_spec* 不為空," +"或是 *format_spec* 或回傳值不是字串,則會引發 :exc:`TypeError`。" #: ../../builtins/functions.rst:849 msgid "" "``object().__format__(format_spec)`` raises :exc:`TypeError` if " "*format_spec* is not an empty string." msgstr "" +"當 *format_spec* 不是空字串時,``object().__format__(format_spec)`` 會引發 :" +"exc:`TypeError`。" #: ../../builtins/functions.rst:858 msgid "" @@ -1318,12 +1615,17 @@ msgid "" "*iterable*. :class:`frozenset` is a built-in class. See also :ref:`types-" "set` for documentation about this class." msgstr "" +"回傳一個新的 :class:`frozenset` 物件,它包含選擇性引數 *iterable* 中的元素。:" +"class:`frozenset` 是一個內建的 class。有關此 class 的文件,亦請參閱 :ref:" +"`types-set`。" #: ../../builtins/functions.rst:862 msgid "" "For other containers see the built-in :class:`set`, :class:`list`, :class:" "`tuple`, and :class:`dict` classes, as well as the :mod:`collections` module." msgstr "" +"請參閱內建的 :class:`set`、:class:`list`、:class:`tuple` 和 :class:`dict` " +"class,以及 :mod:`collections` module 來了解其它的容器。" #: ../../builtins/functions.rst:870 msgid "" @@ -1334,6 +1636,11 @@ msgid "" "exist, *default* is returned if provided, otherwise :exc:`AttributeError` is " "raised. *name* need not be a Python identifier (see :func:`setattr`)." msgstr "" +"回傳 *object* 之具名屬性的值。*name* 必須是字串。如果該字串是物件屬性之一的名" +"稱,則回傳該屬性的值。例如,``getattr(x, 'foobar')`` 等同於 ``x.foobar``。如" +"果指定的屬性不存在,且提供了 *default* 值,則回傳其值,否則引發 :exc:" +"`AttributeError`。*name* 不必是個 Python 識別符 (identifier)(請見 :func:" +"`setattr`)。" #: ../../builtins/functions.rst:879 msgid "" @@ -1342,6 +1649,9 @@ msgid "" "with two leading underscores) name in order to retrieve it with :func:" "`getattr`." msgstr "" +"由於\\ :ref:`私有名稱改編 (private name mangling) ` 是" +"發生在編譯期,因此你必須手動改編私有屬性(有兩個前導底線的屬性)的名稱,才能" +"使用 :func:`getattr` 來取得它。" #: ../../builtins/functions.rst:887 msgid "" @@ -1349,6 +1659,8 @@ msgid "" "within functions, this is set when the function is defined and remains the " "same regardless of where the function is called." msgstr "" +"回傳代表目前 module 命名空間的 dictionary。對於在函式中的程式碼來說,這在定義" +"函式時設定且不論該函式是在何處呼叫都會保持相同。" #: ../../builtins/functions.rst:894 msgid "" @@ -1357,6 +1669,9 @@ msgid "" "(This is implemented by calling ``getattr(object, name)`` and seeing whether " "it raises an :exc:`AttributeError` or not.)" msgstr "" +"該引數是一個物件和一個字串。如果字串是物件屬性之一的名稱,則回傳 ``True``,否" +"則回傳 ``False``。(此功能是透過呼叫 ``getattr(object, name)`` 並檢查是否引" +"發 :exc:`AttributeError` 來實作的。)" #: ../../builtins/functions.rst:902 msgid "" @@ -1365,12 +1680,17 @@ msgid "" "dictionary lookup. Numeric values that compare equal have the same hash " "value (even if they are of different types, as is the case for 1 and 1.0)." msgstr "" +"回傳該物件的雜湊值(如果它有的話)。雜湊值是整數。它們在 dictionary 查詢元素" +"時用來快速比較 dictionary 的鍵。相同大小的數字數值有相同的雜湊值(即使它們型" +"別不同,如 1 和 1.0)。" #: ../../builtins/functions.rst:909 msgid "" "For objects with custom :meth:`~object.__hash__` methods, note that :func:" "`hash` truncates the return value based on the bit width of the host machine." msgstr "" +"請注意,如果物件帶有自訂的 :meth:`~object.__hash__` 方法,:func:`hash` 將根據" +"運行機器的位元長度來截斷回傳值。" #: ../../builtins/functions.rst:916 msgid "" @@ -1381,6 +1701,10 @@ msgid "" "documentation topic, and a help page is printed on the console. If the " "argument is any other kind of object, a help page on the object is generated." msgstr "" +"啟動內建的幫助系統(此函式主要以互動式使用)。如果沒有引數,直譯器控制台裡會" +"啟動互動式幫助系統。如果引數是一個字串,則會在 module、函式、class、method、" +"關鍵字或說明文件主題中搜尋該字串,並在控制台上列印幫助資訊。如果引數是其他任" +"意物件,則會生成該物件的幫助頁。" #: ../../builtins/functions.rst:923 msgid "" @@ -1389,17 +1713,22 @@ msgid "" "positional-only. For more info, see :ref:`the FAQ entry on positional-only " "parameters `." msgstr "" +"請注意,呼叫 :func:`help` 時,如果斜線 (/) 出現在函式的參數列表中,這表示斜線" +"前面的參數是僅限位置 (positional-only) 參數。有關更多資訊,請參閱\\ :ref:`常" +"見問答集中的僅限位置參數條目 `。" #: ../../builtins/functions.rst:928 msgid "" "This function is added to the built-in namespace by the :mod:`site` module." -msgstr "" +msgstr "此函式會被 :mod:`site` module 加入到內建命名空間。" #: ../../builtins/functions.rst:930 msgid "" "Changes to :mod:`pydoc` and :mod:`inspect` mean that the reported signatures " "for callables are now more comprehensive and consistent." msgstr "" +"對於 :mod:`pydoc` 和 :mod:`inspect` 的變更,使得可呼叫物件回報的的簽名 " +"(signature) 更加全面和一致。" #: ../../builtins/functions.rst:937 msgid "" @@ -1407,6 +1736,9 @@ msgid "" "\"0x\". If *integer* is not a Python :class:`int` object, it has to define " "an :meth:`~object.__index__` method that returns an integer. Some examples:" msgstr "" +"將整數轉換為以 \"0x\" 為前綴的小寫十六進位制字串。如果 *integer* 不是 " +"Python :class:`int` 物件,則必須定義一個 :meth:`~object.__index__` method 並" +"且回傳一個整數。舉例來說:" #: ../../builtins/functions.rst:946 msgid "" @@ -1414,18 +1746,21 @@ msgid "" "hexadecimal string with prefix or not, you can use either of the following " "ways:" msgstr "" +"如果要將整數轉換為大寫或小寫的十六進位制字串,並可選擇有無 \"0x\" 前綴,則可" +"以使用如下方法:" #: ../../builtins/functions.rst:958 msgid "" "See also :func:`int` for converting a hexadecimal string to an integer using " "a base of 16." -msgstr "" +msgstr "另請參閱 :func:`int` 將十六進位制字串轉換為以 16 為基數的整數。" #: ../../builtins/functions.rst:963 msgid "" "To obtain a hexadecimal string representation for a float, use the :meth:" "`float.hex` method." msgstr "" +"如果要取得浮點數的十六進位制字串形式,請使用 :meth:`float.hex` method。" #: ../../builtins/functions.rst:969 msgid "" @@ -1434,16 +1769,19 @@ msgid "" "Two objects with non-overlapping lifetimes may have the same :func:`id` " "value." msgstr "" +"回傳物件的 \"識別性\" 。該值是一個整數,在此物件的生命週期中保證是唯一且恆定" +"的。兩個生命期不重疊的物件可能具有相同的 :func:`id` 值。" #: ../../builtins/functions.rst:974 msgid "This is the address of the object in memory." -msgstr "" +msgstr "這是該物件在記憶體中的位址。" #: ../../builtins/functions.rst:976 msgid "" "Raises an :ref:`auditing event ` ``builtins.id`` with argument " "``id``." msgstr "" +"引發一個附帶引數 ``id`` 的\\ :ref:`稽核事件 ` ``builtins.id``。" #: ../../builtins/functions.rst:982 msgid "" @@ -1452,6 +1790,9 @@ msgid "" "converts it to a string (stripping a trailing newline), and returns that. " "When EOF is read, :exc:`EOFError` is raised. Example::" msgstr "" +"如果有提供 *prompt* 引數,則將其寫入標準輸出,末尾不帶換行符。接下來,該函式" +"從輸入中讀取一行,將其轉換為字串(去除末尾的換行符)並回傳。當讀取到 EOF 時," +"則引發 :exc:`EOFError`。例如: ::" #: ../../builtins/functions.rst:987 msgid "" @@ -1460,30 +1801,40 @@ msgid "" ">>> s\n" "\"Monty Python's Flying Circus\"" msgstr "" +">>> s = input('--> ')\n" +"--> Monty Python's Flying Circus\n" +">>> s\n" +"\"Monty Python's Flying Circus\"" #: ../../builtins/functions.rst:992 msgid "" "If the :mod:`readline` module was loaded, then :func:`input` will use it to " "provide elaborate line editing and history features." msgstr "" +"如果載入了 :mod:`readline` module,:func:`input` 將使用它來提供複雜的行編輯和" +"歷史記錄功能。" #: ../../builtins/functions.rst:995 ../../builtins/functions.rst:997 msgid "" "Raises an :ref:`auditing event ` ``builtins.input`` with argument " "``prompt`` before reading input" msgstr "" +"引發一個附帶讀取輸入前的引數 ``prompt`` 的\\ :ref:`稽核事件 ` " +"``builtins.input``。" #: ../../builtins/functions.rst:1000 ../../builtins/functions.rst:1002 msgid "" "Raises an :ref:`auditing event ` ``builtins.input/result`` with " "the result after successfully reading input." msgstr "" +"引發一個附帶成功讀取結果的\\ :ref:`稽核事件 ` ``builtins.input/" +"result``。" #: ../../builtins/functions.rst:1009 msgid "" "Return an integer object constructed from a number or a string, or return " "``0`` if no arguments are given." -msgstr "" +msgstr "回傳一個由數字或字串所構成的整數物件,若沒有給引數則回傳 ``0``。" #: ../../builtins/functions.rst:1014 msgid "" @@ -1500,6 +1851,18 @@ msgid "" ">>> int('01110011', base=2)\n" "115" msgstr "" +">>> int(123.45)\n" +"123\n" +">>> int('123')\n" +"123\n" +">>> int(' -12_345\\n')\n" +"-12345\n" +">>> int('FACE', 16)\n" +"64206\n" +">>> int('0xface', 0)\n" +"64206\n" +">>> int('01110011', base=2)\n" +"115" #: ../../builtins/functions.rst:1029 msgid "" @@ -1507,6 +1870,9 @@ msgid "" "__int__()``. If the argument defines :meth:`~object.__index__`, it returns " "``x.__index__()``. For floating-point numbers, this truncates towards zero." msgstr "" +"如果引數定義了 :meth:`~object.__int__`,則 ``int(x)`` 會回傳 ``x." +"__int__()``。如果引數定義了 :meth:`~object.__index__` 則回傳 ``x." +"__index__()``。對於浮點數,則會向零的方向無條件捨去。" #: ../../builtins/functions.rst:1034 msgid "" @@ -1516,6 +1882,10 @@ msgid "" "``-`` (with no space in between), have leading zeros, be surrounded by " "whitespace, and have single underscores interspersed between digits." msgstr "" +"如果引數不是數字或如果有給定 *base*,則它必須是個字串、:class:`bytes` 或 :" +"class:`bytearray` 實例,表示基數 (radix) *base* 中的整數。可選地,字串之前可" +"以有 ``+`` 或 ``-``\\ (中間沒有空格)、可有個前導的零、也可被空格包圍、或在" +"數字間有單一底線。" #: ../../builtins/functions.rst:1040 msgid "" @@ -1530,10 +1900,18 @@ msgid "" "prefix. Base 0 also disallows leading zeros: ``int('010', 0)`` is not legal, " "while ``int('010')`` and ``int('010', 8)`` are." msgstr "" +"一個 n 進制的整數字串,包含各個代表 0 到 n-1 的數字,0–9 可以用任何 Unicode " +"十進制數字表示,10–35 可以用 ``a`` 到 ``z``\\ (或 ``A`` 到 ``Z``\\ )表示。" +"預設的 *base* 是 10。允許的進位制有 0、2–36。2、8、16 進位制的字串可以在程式" +"碼中用 ``0b``/``0B``、``0o``/``0O``、``0x``/``0X`` 前綴來表示,如同程式碼中的" +"整數文字。進位制為 0 的字串將以和\\ :ref:`程式碼整數字面值 (integer literal " +"in code) ` 類似的方式來直譯,最後由前綴決定的結果會是 2、8、10、16 " +"進制中的一個,所以 ``int('010', 0)`` 是非法的,但 ``int('010')`` 和 " +"``int('010', 8)`` 是有效的。" #: ../../builtins/functions.rst:1051 msgid "The integer type is described in :ref:`typesnumeric`." -msgstr "" +msgstr "整數型別定義請參閱\\ :ref:`typesnumeric`。" #: ../../builtins/functions.rst:1053 msgid "" @@ -1542,16 +1920,21 @@ msgid "" "obtain an integer for the base. Previous versions used :meth:`base.__int__ " "` instead of :meth:`base.__index__ `." msgstr "" +"如果 *base* 不是 :class:`int` 的實例,但 *base* 物件有 :meth:`base.__index__ " +"` method,則會呼叫該 method 來取得此進位制所需的整數。以前" +"的版本使用 :meth:`base.__int__ ` 而不是 :meth:`base." +"__index__ `。" #: ../../builtins/functions.rst:1063 msgid "The first parameter is now positional-only." -msgstr "" +msgstr "第一個參數為僅限位置參數。" #: ../../builtins/functions.rst:1066 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not " "defined." msgstr "" +"如果未定義 :meth:`~object.__int__` 則會回退到 :meth:`~object.__index__`。" #: ../../builtins/functions.rst:1069 msgid "" @@ -1562,11 +1945,15 @@ msgid "" "ref:`integer string conversion length limitation ` " "documentation." msgstr "" +":class:`int` 的字串輸入和字串表示法可以被限制,以避免阻斷服務攻擊 (denial of " +"service attack)。在字串 *x* 轉換為 :class:`int` 時已超出限制,或是在 :class:" +"`int` 轉換為字串時將會超出限制時,會引發 :exc:`ValueError`。請參閱\\ :ref:`整" +"數字串轉換的長度限制 `\\ 說明文件。" #: ../../builtins/functions.rst:1077 msgid "" ":func:`int` no longer delegates to the :meth:`~object.__trunc__` method." -msgstr "" +msgstr ":func:`int` 不再委派給 :meth:`~object.__trunc__` method。" #: ../../builtins/functions.rst:1082 msgid "" @@ -1580,10 +1967,18 @@ msgid "" "exc:`TypeError` exception is raised. :exc:`TypeError` may not be raised for " "an invalid type if an earlier check succeeds." msgstr "" +"如果 *object* 引數是 *classinfo* 引數的實例,或者是(直接、間接或 :term:" +"`virtual `)subclass 的實例,則回傳 ``True``。如果 " +"*object* 不是給定型別的物件,函式始終回傳 ``False``。如果 *classinfo* 是包含" +"物件型別的 tuple(或多個遞迴 tuple)或一個包含多種型別的 :ref:`types-union`," +"若 *object* 是其中的任何一個物件的實例則回傳 ``True``。如果 *classinfo* 既不" +"是型別,也不是型別 tuple 或型別的遞迴 tuple,那麼會引發 :exc:`TypeError` 異" +"常。若是先前檢查已經成功,:exc:`TypeError` 可能不會再因為不合格的型別而被引" +"發。" #: ../../builtins/functions.rst:1093 ../../builtins/functions.rst:1107 msgid "*classinfo* can be a :ref:`types-union`." -msgstr "" +msgstr "*classinfo* 可以是一個 :ref:`types-union`。" #: ../../builtins/functions.rst:1099 msgid "" @@ -1594,6 +1989,11 @@ msgid "" "return ``True`` if *class* is a subclass of any entry in *classinfo*. In " "any other case, a :exc:`TypeError` exception is raised." msgstr "" +"如果 *class* 是 *classinfo* 的 subclass(直接、間接或 :term:`virtual " +"`),則回傳 ``True``。*classinfo* 可以是 class 物件的 " +"tuple(或遞迴地其他類似 tuple)或是一個 :ref:`types-union`,此時若 *class* " +"是 *classinfo* 中任一元素的 subclass 時則回傳 ``True``。其他情況,會引發 :" +"exc:`TypeError`。" #: ../../builtins/functions.rst:1114 msgid "" @@ -1610,10 +2010,18 @@ msgid "" "the value returned is equal to *sentinel*, :exc:`StopIteration` will be " "raised, otherwise the value will be returned." msgstr "" +"回傳一個 :term:`iterator` 物件。根據是否存在第二個引數,第一個引數的意義是非" +"常不同的。如果沒有第二個引數,該單一引數必須是支援 :term:`iterable` 協定" +"(有 :meth:`~object.__iter__` method)的集合物件,或必須支援序列協定(有 :" +"meth:`~object.__getitem__` 方法,且數字引數從 ``0`` 開始)。如果它不支援這些" +"協定,會引發 :exc:`TypeError`。如果有第二個引數 *sentinel*,那麼第一引數必須" +"是可呼叫的物件,這種情況下生成的 iterator,每次疊代呼叫 :meth:`~iterator." +"__next__` 時會不帶引數地呼叫 *callable*;如果回傳的結果是 *sentinel* 則引發 :" +"exc:`StopIteration`,否則回傳呼叫結果。" #: ../../builtins/functions.rst:1128 msgid "See also :ref:`typeiter`." -msgstr "" +msgstr "另請參閱 :ref:`typeiter`。" #: ../../builtins/functions.rst:1130 msgid "" @@ -1621,6 +2029,8 @@ msgid "" "block-reader. For example, reading fixed-width blocks from a binary database " "file until the end of file is reached::" msgstr "" +":func:`iter` 的第二種形式有一個好用的應用,是能夠建立一個區塊閱讀器 (block-" +"reader)。例如,從二進位資料庫檔案中讀取固定寬度的區塊,直到檔案的結尾: ::" #: ../../builtins/functions.rst:1134 msgid "" @@ -1629,6 +2039,10 @@ msgid "" " for block in iter(partial(f.read, 64), b''):\n" " process_block(block)" msgstr "" +"from functools import partial\n" +"with open('mydata.db', 'rb') as f:\n" +" for block in iter(partial(f.read, 64), b''):\n" +" process_block(block)" #: ../../builtins/functions.rst:1142 msgid "" @@ -1636,25 +2050,31 @@ msgid "" "sequence (such as a string, bytes, tuple, list, or range) or a collection " "(such as a dictionary, set, or frozen set)." msgstr "" +"回傳物件的長度(元素個數)。引數可以是序列(如 string、bytes、tuple、list 或 " +"range)或集合(如 dictionary、set 或 frozen set)。" #: ../../builtins/functions.rst:1148 msgid "" "``len`` raises :exc:`OverflowError` on lengths larger than :data:`sys." "maxsize`, such as :class:`range(2 ** 100) `." msgstr "" +"如果物件長度大於 :data:`sys.maxsize`,像是 :class:`range(2 ** 100) `," +"則 ``len`` 會引發 :exc:`OverflowError`。" #: ../../builtins/functions.rst:1156 msgid "" "Rather than being a function, :class:`list` is actually a mutable sequence " "type, as documented in :ref:`typesseq-list` and :ref:`typesseq`." msgstr "" +"除了是函式,:class:`list` 也是可變序列型別,詳情請參閱 :ref:`typesseq-list` " +"和 :ref:`typesseq`。" #: ../../builtins/functions.rst:1162 msgid "" "Return a mapping object representing the current local symbol table, with " "variable names as the keys, and their currently bound references as the " "values." -msgstr "" +msgstr "回傳代表目前區域符號表的對映物件,變數名稱為鍵,目前綁定的參照為值。" #: ../../builtins/functions.rst:1166 msgid "" @@ -1662,18 +2082,23 @@ msgid "" "single namespace, this function returns the same namespace as :func:" "`globals`." msgstr "" +"在模組作用域,以及使用 :func:`exec` 或 :func:`eval` 單一命名空間時,此函式會" +"回傳與 :func:`globals` 相同的命名空間。" #: ../../builtins/functions.rst:1170 msgid "" "At class scope, it returns the namespace that will be passed to the " "metaclass constructor." msgstr "" +"在類別作用域中,它會回傳將傳遞給元類別 (metaclass) 建構函式的命名空間。" #: ../../builtins/functions.rst:1173 msgid "" "When using ``exec()`` or ``eval()`` with separate local and global " "arguments, it returns the local namespace passed in to the function call." msgstr "" +"當使用 ``exec()`` 或 ``eval()``,並分別使用本機和全局參數時,它會回傳傳入函式" +"呼叫的本機命名空間。" #: ../../builtins/functions.rst:1176 msgid "" @@ -1684,6 +2109,10 @@ msgid "" "deleting local variables will immediately affect the contents of the " "returned mapping object." msgstr "" +"在上述所有情況下,在指定的執行框架中,每次呼叫 ``locals()`` 都會回傳\\ *相同" +"*\\ 的對映物件。透過 ``locals()`` 回傳的對映物件所做的變更,會以被指派、重新" +"指派或刪除的區域變數的形式顯示,而指派、重新指派或刪除區域變數會立即影響回傳" +"的對映物件的內容。" #: ../../builtins/functions.rst:1183 msgid "" @@ -1696,6 +2125,11 @@ msgid "" "variables and nonlocal cell references does *not* affect the contents of " "previously returned dictionaries." msgstr "" +"在\\ :term:`optimized scope` 中(包括函式、產生器和協程),每次呼叫 " +"``locals()`` 都會回傳一個新的字典,其中包含函式的區域變數和任何非區域 cell 參" +"照的目前綁定。在這種情況下,透過回傳的字典所做的名稱綁定變更,\\ **不會**\\ " +"寫回對應的區域變數或非區域 cell 參照,而且指派、重新指派或刪除區域變數和非區" +"域 cell 參照,\\ **不會**\\ 影響先前回傳字典的內容。" #: ../../builtins/functions.rst:1192 msgid "" @@ -1705,18 +2139,23 @@ msgid "" "other scopes, it behaves as if the comprehension were running as a nested " "function." msgstr "" +"在函式、產生器或協程中作為綜合運算的一部分呼叫 ``locals()`` 等同於在包含的作" +"用域中呼叫它,但綜合運算已初始化的疊代變數將被包含在內。在其他作用域中,它的" +"行為就像綜合運算作為巢狀函式運行一樣。" #: ../../builtins/functions.rst:1198 msgid "" "Calling ``locals()`` as part of a generator expression is equivalent to " "calling it in a nested generator function." msgstr "" +"呼叫 ``locals()`` 作為產生器運算式的一部分,等同於在巢狀的產生器函式中呼叫" +"它。" #: ../../builtins/functions.rst:1201 msgid "" "The behaviour of ``locals()`` in a comprehension has been updated as " "described in :pep:`709`." -msgstr "" +msgstr "如 :pep:`709` 所述,更新了綜合運算中 ``locals()`` 的行為。" #: ../../builtins/functions.rst:1205 msgid "" @@ -1726,6 +2165,9 @@ msgid "" "being defined, the behaviour in other scopes remains unchanged from previous " "versions." msgstr "" +"作為 :pep:`667` 的一部分,現在定義了變更此函式回傳的對映物件的語意。在 :term:" +"`optimized scopes ` 中的行為現在如上所述。除了被定義外,其他" +"作用域中的行為與先前版本保持不變。" #: ../../builtins/functions.rst:1215 msgid "" @@ -1738,16 +2180,23 @@ msgid "" "raised. For cases where the function inputs are already arranged into " "argument tuples, see :func:`itertools.starmap`." msgstr "" +"產生一個將 *function* 應用於 *iterable* 中所有項目並 yield 回傳結果的疊代器。" +"如果傳遞了額外的 *iterables* 引數,則 *function* 必須接受相同個數的引數,且 " +"*function* 會平行地被應用於所有可疊代物件的項目。當有多個可疊代物件時,項目最" +"少的可疊代物件\\ :term:`耗盡 `\\ 時疊代器也會結束。如果 *strict* " +"為 ``True`` 且其中一個可疊代物件在其他可疊代物件之前耗盡,則會拋出 :exc:" +"`ValueError`。如果函式的輸入已經被編排為引數的元組,請參閱 :func:`itertools." +"starmap`。" #: ../../builtins/functions.rst:1224 msgid "Added the *strict* parameter." -msgstr "" +msgstr "增加了 *strict* 參數。" #: ../../builtins/functions.rst:1232 msgid "" "Return the largest item in an iterable or the largest of two or more " "arguments." -msgstr "" +msgstr "回傳 iterable 中最大的元素,或者回傳兩個以上的引數中最大的。" #: ../../builtins/functions.rst:1235 msgid "" @@ -1755,6 +2204,8 @@ msgid "" "The largest item in the iterable is returned. If two or more positional " "arguments are provided, the largest of the positional arguments is returned." msgstr "" +"如果只提供了一個位置引數,它必須是個 :term:`iterable`,iterable 中最大的元素" +"會被回傳。如果提供了兩個或以上的位置引數,則回傳最大的位置引數。" #: ../../builtins/functions.rst:1240 ../../builtins/functions.rst:1278 msgid "" @@ -1764,6 +2215,10 @@ msgid "" "empty. If the iterable is empty and *default* is not provided, a :exc:" "`ValueError` is raised." msgstr "" +"這個函式有兩個選擇性的僅限關鍵字引數。*key* 引數能指定單一引數所使用的排序函" +"式,如同 :meth:`list.sort` 的使用方式。*default* 引數是當 iterable 為空時回傳" +"的物件。如果 iterable 為空,並且沒有提供 *default*,則會引發 :exc:" +"`ValueError`。" #: ../../builtins/functions.rst:1246 msgid "" @@ -1772,26 +2227,31 @@ msgid "" "such as ``sorted(iterable, key=keyfunc, reverse=True)[0]`` and ``heapq." "nlargest(1, iterable, key=keyfunc)``." msgstr "" +"如果有多個最大元素,則此函式將回傳第一個找到的。這和其他穩定排序工具如 " +"``sorted(iterable, key=keyfunc, reverse=True)[0]`` 和 ``heapq.nlargest(1, " +"iterable, key=keyfunc)`` 一致。" #: ../../builtins/functions.rst:1251 ../../builtins/functions.rst:1289 msgid "Added the *default* keyword-only parameter." -msgstr "" +msgstr "新增 *default* 僅限關鍵字參數。" #: ../../builtins/functions.rst:1254 ../../builtins/functions.rst:1292 msgid "The *key* can be ``None``." -msgstr "" +msgstr "*key* 可以為 ``None``。" #: ../../builtins/functions.rst:1262 msgid "" "Return a \"memory view\" object created from the given argument. See :ref:" "`typememoryview` for more information." msgstr "" +"回傳由給定的引數所建立之「memory view(記憶體檢視)」物件。有關詳細資訊,請參" +"閱\\ :ref:`typememoryview`。" #: ../../builtins/functions.rst:1270 msgid "" "Return the smallest item in an iterable or the smallest of two or more " "arguments." -msgstr "" +msgstr "回傳 iterable 中最小的元素,或者回傳兩個以上的引數中最小的。" #: ../../builtins/functions.rst:1273 msgid "" @@ -1799,6 +2259,8 @@ msgid "" "The smallest item in the iterable is returned. If two or more positional " "arguments are provided, the smallest of the positional arguments is returned." msgstr "" +"如果只提供了一個位置引數,它必須是 :term:`iterable`,iterable 中最小的元素會" +"被回傳。如果提供了兩個以上的位置引數,則回傳最小的位置引數。" #: ../../builtins/functions.rst:1284 msgid "" @@ -1807,6 +2269,9 @@ msgid "" "such as ``sorted(iterable, key=keyfunc)[0]`` and ``heapq.nsmallest(1, " "iterable, key=keyfunc)``." msgstr "" +"如果有多個最小元素,則此函式將回傳第一個找到的。這和其他穩定排序工具如 " +"``sorted(iterable, key=keyfunc)[0]`` 和 ``heapq.nsmallest(1, iterable, " +"key=keyfunc)`` 一致。" #: ../../builtins/functions.rst:1299 msgid "" @@ -1814,6 +2279,9 @@ msgid "" "`~iterator.__next__` method. If *default* is given, it is returned if the " "iterator is :term:`exhausted`, otherwise :exc:`StopIteration` is raised." msgstr "" +"透過呼叫 :term:`iterator` 的 :meth:`~iterator.__next__` method 取得下一個元" +"素。如果 iterator 已\\ :term:`耗盡 `,則回傳給定的預設值 " +"*default*,如果沒有預設值則引發 :exc:`StopIteration`。" #: ../../builtins/functions.rst:1306 msgid "" @@ -1822,12 +2290,17 @@ msgid "" "called, it returns a new featureless object. The constructor does not accept " "any arguments." msgstr "" +"這是所有其他 class 的基礎,它具有所有 Python class 實例的通用 method。當建構" +"函式被呼叫時,它會回傳一個新的沒有特徵 (featureless) 的物件。這個建構函式不接" +"受任何引數。" #: ../../builtins/functions.rst:1313 msgid "" ":class:`object` instances do *not* have :attr:`~object.__dict__` attributes, " "so you can't assign arbitrary attributes to an instance of :class:`object`." msgstr "" +"由於 :class:`object` 實例\\ *沒有* :attr:`~object.__dict__` 屬性,因此無法將" +"任意屬性賦給 :class:`object` 的實例。" #: ../../builtins/functions.rst:1320 msgid "" @@ -1836,12 +2309,17 @@ msgid "" "`int` object, it has to define an :meth:`~object.__index__` method that " "returns an integer. For example:" msgstr "" +"將一個整數轉變為一個前綴為 \"0o\" 的八進位制字串。回傳結果是一個有效的 " +"Python 運算式。如果 *integer* 不是 Python 的 :class:`int` 物件,那它需要定" +"義 :meth:`~object.__index__` method 回傳一個整數。舉例來說:" #: ../../builtins/functions.rst:1330 msgid "" "If you want to convert an integer number to an octal string either with the " "prefix \"0o\" or not, you can use either of the following ways." msgstr "" +"如果要將整數轉換為八進位制字串,不論是否具備 \"0o\" 前綴,都可以使用下面的方" +"法。" #: ../../builtins/functions.rst:1347 msgid "" @@ -1849,6 +2327,9 @@ msgid "" "cannot be opened, an :exc:`OSError` is raised. See :ref:`tut-files` for more " "examples of how to use this function." msgstr "" +"開啟 *file* 並回傳對應的\\ :term:`檔案物件 `。如果該檔案不能開" +"啟,則引發 :exc:`OSError`。關於使用此函式的更多方法,請參閱\\ :ref:`tut-" +"files`。" #: ../../builtins/functions.rst:1351 msgid "" @@ -1858,6 +2339,10 @@ msgid "" "given, it is closed when the returned I/O object is closed unless *closefd* " "is set to ``False``.)" msgstr "" +"*file* 是一個\\ :term:`類路徑物件 `,是將被開啟之檔案的路徑" +"(絕對路徑或目前工作目錄的相對路徑),或是要被包裝 (wrap) 檔案的整數檔案描述" +"器 (file descriptor)。(如果有給定檔案描述器,它會隨著回傳的 I/O 物件關閉而關" +"閉,除非 *closefd* 被設為 ``False``。)" #: ../../builtins/functions.rst:1357 msgid "" @@ -1872,70 +2357,77 @@ msgid "" "reading and writing raw bytes use binary mode and leave *encoding* " "unspecified.) The available modes are:" msgstr "" +"*mode* 是一個選擇性字串,用於指定開啟檔案的模式。預設值是 ``'r'``,這意味著它" +"以文字模式開啟並讀取。其他常見模式有:寫入 ``'w'``\\ (會捨去已經存在的檔" +"案)、唯一性建立 ``'x'``、追加寫入 ``'a'``\\ (在\\ *一些* Unix 系統上,無論" +"目前的檔案指標在什麼位置,*所有* 寫入都會追加到檔案末尾)。在文字模式,如果沒" +"有指定 *encoding*,則根據電腦平臺來決定使用的編碼:呼叫 :func:`locale." +"getencoding` 來取得目前的本地編碼。(要讀取和寫入原始 bytes,請使用二進位制模" +"式且不要指定 *encoding*。)可用的模式有:" #: ../../builtins/functions.rst:1374 msgid "Character" -msgstr "" +msgstr "字元" #: ../../builtins/functions.rst:1374 msgid "Meaning" -msgstr "" +msgstr "意義" #: ../../builtins/functions.rst:1376 msgid "``'r'``" -msgstr "" +msgstr "``'r'``" #: ../../builtins/functions.rst:1376 msgid "open for reading (default)" -msgstr "" +msgstr "讀取(預設)" #: ../../builtins/functions.rst:1377 msgid "``'w'``" -msgstr "" +msgstr "``'w'``" #: ../../builtins/functions.rst:1377 msgid "open for writing, truncating the file first" -msgstr "" +msgstr "寫入,會先清除檔案內容" #: ../../builtins/functions.rst:1378 msgid "``'x'``" -msgstr "" +msgstr "``'x'``" #: ../../builtins/functions.rst:1378 msgid "open for exclusive creation, failing if the file already exists" -msgstr "" +msgstr "唯一性建立,如果文件已存在則會失敗" #: ../../builtins/functions.rst:1379 msgid "``'a'``" -msgstr "" +msgstr "``'a'``" #: ../../builtins/functions.rst:1379 msgid "open for writing, appending to the end of file if it exists" -msgstr "" +msgstr "寫入,如果檔案存在則在其末端附加內容" #: ../../builtins/functions.rst:1380 msgid "``'b'``" -msgstr "" +msgstr "``'b'``" #: ../../builtins/functions.rst:1380 ../../builtins/functions.rst:1524 msgid "binary mode" -msgstr "" +msgstr "二進制模式" #: ../../builtins/functions.rst:1381 msgid "``'t'``" -msgstr "" +msgstr "``'t'``" #: ../../builtins/functions.rst:1381 msgid "text mode (default)" -msgstr "" +msgstr "文字模式(預設)" #: ../../builtins/functions.rst:1382 msgid "``'+'``" -msgstr "" +msgstr "``'+'``" #: ../../builtins/functions.rst:1382 msgid "open for updating (reading and writing)" -msgstr "" +msgstr "更新(讀取並寫入)" #: ../../builtins/functions.rst:1385 msgid "" @@ -1943,6 +2435,9 @@ msgid "" "Modes ``'w+'`` and ``'w+b'`` open and truncate the file. Modes ``'r+'`` and " "``'r+b'`` open the file with no truncation." msgstr "" +"預設的模式是 ``'r'``\\ (開啟並讀取文字,同 ``'rt'``)。``'w+'`` 和 " +"``'w+b'`` 模式會開啟並清除檔案。``'r+'`` 和 ``'r+b'`` 模式會開啟且保留檔案內" +"容。" #: ../../builtins/functions.rst:1389 msgid "" @@ -1954,6 +2449,11 @@ msgid "" "having been first decoded using a platform-dependent encoding or using the " "specified *encoding* if given." msgstr "" +"如\\ :ref:`io-overview`\\ 中所述,Python 能區分二進制和文字的 I/O。在二進制模" +"式下開啟的檔案(*mode* 引數中含有 ``'b'``)會將其內容以 :class:`bytes` 物件回" +"傳,而不進行任何解碼。在文字模式(預設情況,或當 *mode* 引數中含有 " +"``'t'``),檔案的內容會以 :class:`str` 回傳,其位元組已經先被解碼,使用的是取" +"決於平台的編碼系統或是給定的 *encoding*。" #: ../../builtins/functions.rst:1399 msgid "" @@ -1961,6 +2461,8 @@ msgid "" "files; all the processing is done by Python itself, and is therefore " "platform-independent." msgstr "" +"Python 不會使用底層作業系統對於文字檔案的操作概念;所有的處理都是由 Python 獨" +"自完成的,因此能獨立於不同平台。" #: ../../builtins/functions.rst:1403 msgid "" @@ -1974,6 +2476,14 @@ msgid "" "``write_through`` flag for :func:`io.TextIOWrapper.reconfigure`. When no " "*buffering* argument is given, the default buffering policy works as follows:" msgstr "" +"*buffering* 是一個選擇性的整數,用於設定緩衝策略。傳入 0 表示關閉緩衝(僅在二" +"進制模式下被允許),1 表示行緩衝(line buffering,僅在文字模式下可用),而 " +">1 的整數是指示一個大小固定的區塊緩衝區 (chunk buffer),其位元組的數量。請注" +"意,此類指定緩衝區大小的方式適用於二進制緩衝 I/O,但是 ``TextIOWrapper``\\ " +"(以 ``mode='r+'`` 開啟的檔案)會有另一種緩衝方式。若要在 ``TextIOWrapper`` " +"中停用緩衝,可考慮使用 :func:`io.TextIOWrapper.reconfigure` 的 " +"``write_through`` 旗標。若未給定 *buffering* 引數,則預設的緩衝策略會運作如" +"下:" #: ../../builtins/functions.rst:1413 msgid "" @@ -1982,6 +2492,9 @@ msgid "" "size is available. On most systems, the buffer will typically be 128 " "kilobytes long." msgstr "" +"二進位檔案會以固定大小的區塊進行緩衝;緩衝區的大小為 ``max(min(blocksize, 8 " +"MiB), DEFAULT_BUFFER_SIZE)``,當裝置區塊大小可用時。在大多數系統上,緩衝區的" +"長度通常為 128 KB。" #: ../../builtins/functions.rst:1418 msgid "" @@ -1989,6 +2502,8 @@ msgid "" "returns ``True``) use line buffering. Other text files use the policy " "described above for binary files." msgstr "" +"「互動式」文字檔(:meth:`~io.IOBase.isatty` 回傳 ``True`` 的檔案)會使用列緩" +"衝。其他文字檔則使用上述的二進制檔案緩衝策略。" #: ../../builtins/functions.rst:1422 msgid "" @@ -1998,6 +2513,10 @@ msgid "" "encoding` supported by Python can be used. See the :mod:`codecs` module for " "the list of supported encodings." msgstr "" +"*encoding* 是用於解碼或編碼檔案的編碼系統之名稱。它只應該在文字模式下使用。預" +"設的編碼系統會取決於平台(根據 :func:`locale.getencoding` 回傳的內容),但 " +"Python 支援的任何 :term:`text encoding`\\ (文字編碼)都是可以使用的。關於支" +"援的編碼系統清單,請參閱 :mod:`codecs` module。" #: ../../builtins/functions.rst:1428 msgid "" @@ -2007,24 +2526,31 @@ msgid "" "though any error handling name that has been registered with :func:`codecs." "register_error` is also valid. The standard names include:" msgstr "" +"*errors* 是一個選擇性的字串,用於指定要如何處理編碼和解碼的錯誤——它不能在二進" +"制模式下使用。有許多不同的標準錯誤處理程式(error handler,在\\ :ref:`error-" +"handlers`\\ 有列出清單),不過任何已註冊到 :func:`codecs.register_error` 的錯" +"誤處理程式名稱也都是有效的。標準的名稱包括:" #: ../../builtins/functions.rst:1436 msgid "" "``'strict'`` to raise a :exc:`ValueError` exception if there is an encoding " "error. The default value of ``None`` has the same effect." msgstr "" +"``'strict'`` 如果發生編碼錯誤,則引發 :exc:`ValueError` 例外。預設值 " +"``None`` 也有相同的效果。" #: ../../builtins/functions.rst:1440 msgid "" "``'ignore'`` ignores errors. Note that ignoring encoding errors can lead to " "data loss." -msgstr "" +msgstr "``'ignore'`` 忽略錯誤。請注意,忽略編碼錯誤可能導致資料遺失。" #: ../../builtins/functions.rst:1443 msgid "" "``'replace'`` causes a replacement marker (such as ``'?'``) to be inserted " "where there is malformed data." msgstr "" +"``'replace'`` 會在格式不正確的資料位置插入一個替換標誌(像是 ``'?'``)。" #: ../../builtins/functions.rst:1446 msgid "" @@ -2034,6 +2560,10 @@ msgid "" "handler is used when writing data. This is useful for processing files in " "an unknown encoding." msgstr "" +"``'surrogateescape'`` 會將任何不正確的位元組表示為低位代理碼元 (low " +"surrogate code unit),範圍從 U+DC80 到 U+DCFF。在寫入資料時,這些代理碼元將會" +"被還原回 ``surrogateescape`` 錯誤處理程式當時所處理的那些相同位元組。這對於處" +"理未知編碼方式的檔案會很好用。" #: ../../builtins/functions.rst:1453 msgid "" @@ -2041,18 +2571,24 @@ msgid "" "not supported by the encoding are replaced with the appropriate XML " "character reference :samp:`&#{nnn};`." msgstr "" +"``'xmlcharrefreplace'`` 僅在寫入檔案時可支援。編碼系統不支援的字元會被替換為" +"適當的 XML 字元參考 (character reference) ``&#nnn;``。" #: ../../builtins/functions.rst:1457 msgid "" "``'backslashreplace'`` replaces malformed data by Python's backslashed " "escape sequences." msgstr "" +"``'backslashreplace'`` 會用 Python 的反斜線跳脫序列 (backslashed escape " +"sequence) 替換格式不正確的資料。" #: ../../builtins/functions.rst:1460 msgid "" "``'namereplace'`` (also only supported when writing) replaces unsupported " "characters with ``\\N{...}`` escape sequences." msgstr "" +"``'namereplace'``\\ (也僅在寫入時支援)會將不支援的字元替換為 ``\\N{...}`` " +"跳脫序列。" #: ../../builtins/functions.rst:1468 msgid "" @@ -2060,6 +2596,8 @@ msgid "" "be ``None``, ``''``, ``'\\n'``, ``'\\r'``, and ``'\\r\\n'``. It works as " "follows:" msgstr "" +"*newline* 會決定如何剖析資料串流 (stream) 中的換行字元。它可以是 ``None``、" +"``''``、``'\\n'``、``'\\r'`` 或 ``'\\r\\n'``。它的運作規則如下:" #: ../../builtins/functions.rst:1472 msgid "" @@ -2071,6 +2609,11 @@ msgid "" "has any of the other legal values, input lines are only terminated by the " "given string, and the line ending is returned to the caller untranslated." msgstr "" +"從資料串流讀取輸入時,如果 *newline* 是 ``None``,則會啟用通用換行模式。輸入" +"資料中的行結尾可以是 ``'\\n'``、``'\\r'`` 或 ``'\\r\\n'``,這些符號會被轉換" +"為 ``'\\n'`` 之後再回傳給呼叫方。如果是 ``''``,也會啟用通用換行模式,但在回" +"傳給呼叫方時,行尾符號不會被轉換。如果它是任何其他有效的值,則輸入資料的行只" +"會由給定的字串做結尾,且在回傳給呼叫方時,行尾符號不會被轉換。" #: ../../builtins/functions.rst:1480 msgid "" @@ -2080,6 +2623,10 @@ msgid "" "takes place. If *newline* is any of the other legal values, any ``'\\n'`` " "characters written are translated to the given string." msgstr "" +"將輸出寫入資料串流時,如果 *newline* 是 ``None``,則被寫入的任何 ``'\\n'`` 字" +"元都會轉換為系統預設的行分隔符號 :data:`os.linesep`。如果 *newline* 是 " +"``''`` 或 ``'\\n'``,則不做任何轉換。如果 *newline* 是任何其他有效的值,則寫" +"入的任何 ``'\\n'`` 字元都將轉換為給定的字串。" #: ../../builtins/functions.rst:1486 msgid "" @@ -2088,6 +2635,9 @@ msgid "" "closed. If a filename is given *closefd* must be ``True`` (the default); " "otherwise, an error will be raised." msgstr "" +"如果 *closefd* 是 ``False``,且給定的 *file* 引數是一個檔案描述器而不是檔名," +"則當檔案關閉時,底層的檔案描述器會保持開啟狀態。如果有給定一個檔名,則 " +"*closefd* 必須是 ``True``\\ (預設值);否則將引發錯誤。" #: ../../builtins/functions.rst:1491 msgid "" @@ -2097,16 +2647,22 @@ msgid "" "descriptor (passing :mod:`os.open` as *opener* results in functionality " "similar to passing ``None``)." msgstr "" +"透過以 *opener* 傳遞一個可呼叫物件,就可以自訂開啟函式。然後透過以引數 " +"(*file*, *flags*) 呼叫 *opener*,就能取得檔案物件的底層檔案描述器。*opener* " +"必須回傳一個開啟的檔案描述器(將 :mod:`os.open` 作為 *opener* 傳入,在功能上" +"的結果會相當於傳入 ``None``)。" #: ../../builtins/functions.rst:1497 msgid "The newly created file is :ref:`non-inheritable `." -msgstr "" +msgstr "新建立的檔案是\\ :ref:`不可繼承的 `。" #: ../../builtins/functions.rst:1499 msgid "" "The following example uses the :ref:`dir_fd ` parameter of the :func:" "`os.open` function to open a file relative to a given directory::" msgstr "" +"下面的範例使用 :func:`os.open` 函式回傳值當作 :ref:`dir_fd ` 的參數," +"從給定的目錄中用相對路徑開啟檔案: ::" #: ../../builtins/functions.rst:1502 msgid "" @@ -2120,6 +2676,15 @@ msgid "" "...\n" ">>> os.close(dir_fd) # don't leak a file descriptor" msgstr "" +">>> import os\n" +">>> dir_fd = os.open('somedir', os.O_RDONLY)\n" +">>> def opener(path, flags):\n" +"... return os.open(path, flags, dir_fd=dir_fd)\n" +"...\n" +">>> with open('spamspam.txt', 'w', opener=opener) as f:\n" +"... print('This will be written to somedir/spamspam.txt', file=f)\n" +"...\n" +">>> os.close(dir_fd) # don't leak a file descriptor" #: ../../builtins/functions.rst:1512 msgid "" @@ -2135,6 +2700,15 @@ msgid "" "disabled, the raw stream, a subclass of :class:`io.RawIOBase`, :class:`io." "FileIO`, is returned." msgstr "" +":func:`open` 函式回傳的 :term:`file object` 型別取決於模式。當 :func:`open` " +"是在文字模式中開啟檔案時(``'w'``、``'r'``、``'wt'``、``'rt'`` 等),它會回" +"傳 :class:`io.TextIOBase` 的一個 subclass(具體來說,就是 :class:`io." +"TextIOWrapper`)。使用有緩衝的二進制模式開啟檔案時,回傳的 class 則會是 :" +"class:`io.BufferedIOBase` 的 subclass。確切的 class 各不相同:在讀取的二進制" +"模式,它會回傳 :class:`io.BufferedReader`;在寫入和附加的二進制模式,它會回" +"傳 :class:`io.BufferedWriter`,而在讀/寫模式,它會回傳 :class:`io." +"BufferedRandom`。當緩衝被停用時,會回傳原始資料串流 :class:`io.FileIO`,它" +"是 :class:`io.RawIOBase` 的一個 subclass。" #: ../../builtins/functions.rst:1533 msgid "" @@ -2142,40 +2716,47 @@ msgid "" "(where :func:`open` is declared), :mod:`os`, :mod:`os.path`, :mod:" "`tempfile`, and :mod:`shutil`." msgstr "" +"另請參閱檔案操作模組,例如 :mod:`fileinput`、:mod:`io`\\ (定義了 :func:" +"`open` 的 module )、:mod:`os`、:mod:`os.path`、:mod:`tempfile` 以及 :mod:" +"`shutil`。" #: ../../builtins/functions.rst:1537 msgid "" "Raises an :ref:`auditing event ` ``open`` with arguments ``path``, " "``mode``, ``flags``." msgstr "" +"引發一個附帶引數 ``path``、``mode``、``flags`` 的\\ :ref:`稽核事件 " +"` ``open``。" #: ../../builtins/functions.rst:1539 msgid "" "The ``mode`` and ``flags`` arguments may have been modified or inferred from " "the original call." -msgstr "" +msgstr "``mode`` 和 ``flags`` 引數可能會被原始的呼叫所修改或推論 (infer)。" #: ../../builtins/functions.rst:1544 msgid "The *opener* parameter was added." -msgstr "" +msgstr "新增 *opener* 參數。" #: ../../builtins/functions.rst:1545 msgid "The ``'x'`` mode was added." -msgstr "" +msgstr "新增 ``'x'`` 模式。" #: ../../builtins/functions.rst:1546 msgid ":exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`." -msgstr "" +msgstr "過去引發的 :exc:`IOError`,現在是 :exc:`OSError` 的別名。" #: ../../builtins/functions.rst:1547 msgid "" ":exc:`FileExistsError` is now raised if the file opened in exclusive " "creation mode (``'x'``) already exists." msgstr "" +"如果檔案已存在但使用了唯一性建立模式 (``'x'``),現在會引發 :exc:" +"`FileExistsError`。" #: ../../builtins/functions.rst:1552 msgid "The file is now non-inheritable." -msgstr "" +msgstr "檔案在此版本開始是不可繼承的。" #: ../../builtins/functions.rst:1556 msgid "" @@ -2183,28 +2764,32 @@ msgid "" "exception, the function now retries the system call instead of raising an :" "exc:`InterruptedError` exception (see :pep:`475` for the rationale)." msgstr "" +"如果系統呼叫被中斷,但訊號處理程式沒有引發例外,此函式現在會重試系統呼叫,而" +"不是引發 :exc:`InterruptedError` 例外(原因詳見 :pep:`475`)。" #: ../../builtins/functions.rst:1559 msgid "The ``'namereplace'`` error handler was added." -msgstr "" +msgstr "增加了 ``'namereplace'`` 錯誤處理程式。" #: ../../builtins/functions.rst:1563 msgid "Support added to accept objects implementing :class:`os.PathLike`." -msgstr "" +msgstr "增加對於實作 :class:`os.PathLike` 物件的支援。" #: ../../builtins/functions.rst:1564 msgid "" "On Windows, opening a console buffer may return a subclass of :class:`io." "RawIOBase` other than :class:`io.FileIO`." msgstr "" +"在 Windows 上,開啟一個控制臺緩衝區可能會回傳 :class:`io.RawIOBase` 的 " +"subclass,而不是 :class:`io.FileIO`。" #: ../../builtins/functions.rst:1567 msgid "The ``'U'`` mode has been removed." -msgstr "" +msgstr "``'U'`` 模式被移除。" #: ../../builtins/functions.rst:1572 msgid "Return the ordinal value of a character." -msgstr "" +msgstr "回傳一個字元的序數值。" #: ../../builtins/functions.rst:1574 msgid "" @@ -2213,6 +2798,9 @@ msgid "" "``ord('€')`` (Euro sign) returns ``8364``. This is the inverse of :func:" "`chr`." msgstr "" +"如果引數是單字元字串,則回傳該字元的 Unicode 編碼位置。例如 ``ord('a')`` 回傳" +"整數 ``97``、``ord('€')``\\ (歐元符號)回傳 ``8364``。這是 :func:`chr` 的逆" +"函式。" #: ../../builtins/functions.rst:1579 msgid "" @@ -2220,6 +2808,8 @@ msgid "" "1, return its single byte value. For example, ``ord(b'a')`` returns the " "integer ``97``." msgstr "" +"如果引數是長度為 1 的 :class:`bytes` 或 :class:`bytearray` 物件,則回傳其單一" +"位元組值。例如 ``ord(b'a')`` 回傳整數 ``97``。" #: ../../builtins/functions.rst:1586 msgid "" @@ -2228,6 +2818,9 @@ msgid "" "mod``). The two-argument form ``pow(base, exp)`` is equivalent to using the " "power operator: ``base**exp``." msgstr "" +"回傳 *base* 的 *exp* 次方;如果 *mod* 存在,則回傳 *base* 的 *exp* 次方對 " +"*mod* 取餘數(比直接呼叫 ``pow(base, exp) % mod`` 計算更高效)。兩個引數形式" +"的 ``pow(exp, exp)`` 等價於次方運算子:``base**exp``。" #: ../../builtins/functions.rst:1591 msgid "" @@ -2243,6 +2836,15 @@ msgid "" "`float` with an integral exponent, a float result is delivered. For example, " "``pow(-9, 2.0)`` returns ``81.0``." msgstr "" +"當引數為內建數值型別且運算元型別為混合型別時,會套用二元算術運算子的強制轉型 " +"(coercion) 規則。對於 :class:`int` 運算元,運算結果會(在強制轉型後)與運算元" +"的型別相同,除非第二個引數是負數;在這種情況下,所有的引數都會被轉換為浮點數" +"並得到浮點數的結果。例如,``pow(10, 2)`` 會回傳 ``100``,但 ``pow(10, -2)`` " +"會回傳 ``0.01``。如果底數 (base) 是型別為 :class:`int` 或 :class:`float` 的負" +"數且指數 (exponent) 為非整數,則會傳回複數結果。例如 ``pow(-9, 0.5)`` 會回傳" +"一個接近 ``3j`` 的值。然而,如果底數 (base) 是型別為 :class:`int` 或 :class:" +"`float` 的負數且指數為整數,則會傳回浮點數結果。例如 ``pow(-9, 2.0)`` 會回傳 " +"``81.0``。" #: ../../builtins/functions.rst:1603 msgid "" @@ -2252,10 +2854,14 @@ msgid "" "``pow(inv_base, -exp, mod)`` is returned, where *inv_base* is an inverse to " "*base* modulo *mod*." msgstr "" +"對於 :class:`int` 運算元 *base* 和 *exp*,如果有給定 *mod*,則 *mod* 也必須是" +"整數型別,且 *mod* 必須不為零。如果有給定 *mod* 且 *exp* 為負,則 *base* 必須" +"與 *mod* 互質。在這種情況下,會回傳 ``pow(inv_base, -exp, mod)``,其中 " +"*inv_base* 是 *base* 對 *mod* 的模倒數 (inverse modulo)。" #: ../../builtins/functions.rst:1609 msgid "Here's an example of computing an inverse for ``38`` modulo ``97``::" -msgstr "" +msgstr "以下是一個計算 ``38`` 對 ``97`` 取模倒數的範例: ::" #: ../../builtins/functions.rst:1611 msgid "" @@ -2264,17 +2870,23 @@ msgid "" ">>> 23 * 38 % 97 == 1\n" "True" msgstr "" +">>> pow(38, -1, mod=97)\n" +"23\n" +">>> 23 * 38 % 97 == 1\n" +"True" #: ../../builtins/functions.rst:1616 msgid "" "For :class:`int` operands, the three-argument form of ``pow`` now allows the " "second argument to be negative, permitting computation of modular inverses." msgstr "" +"對於 :class:`int` 運算元,現在 ``pow`` 的三引數形式允許第二個引數為負數,也容" +"許模倒數的計算。" #: ../../builtins/functions.rst:1621 msgid "" "Allow keyword arguments. Formerly, only positional arguments were supported." -msgstr "" +msgstr "允許關鍵字引數。在此之前只支援位置引數。" #: ../../builtins/functions.rst:1628 msgid "" @@ -2282,6 +2894,8 @@ msgid "" "by *end*. *sep*, *end*, *file*, and *flush*, if present, must be given as " "keyword arguments." msgstr "" +"將 *objects* 列印到文字資料串流 *file*,用 *sep* 分隔並以 *end* 結尾。如果有" +"給定 *sep*、*end*、*file* 和 *flush*,那麼它們必須是關鍵字引數的形式。" #: ../../builtins/functions.rst:1632 msgid "" @@ -2291,6 +2905,10 @@ msgid "" "default values. If no *objects* are given, :func:`print` will just write " "*end*." msgstr "" +"所有的非關鍵字引數都會像是 :func:`str` 操作一樣地被轉換為字串,並寫入資料串" +"流,彼此以 *sep* 分隔,並以 *end* 結尾。*sep* 和 *end* 都必須是字串;它們也可" +"以是 ``None``,這表示使用預設值。如果沒有給定 *objects*,:func:`print` 就只會" +"寫入 *end*。" #: ../../builtins/functions.rst:1638 msgid "" @@ -2299,20 +2917,26 @@ msgid "" "arguments are converted to text strings, :func:`print` cannot be used with " "binary mode file objects. For these, use ``file.write(...)`` instead." msgstr "" +"*file* 引數必須是一個有 ``write(string)`` method 的物件;如果沒有給定或被設" +"為 ``None``,則將使用 :data:`sys.stdout`。因為要列印的引數會被轉換為文字字" +"串,所以 :func:`print` 不能用於二進位模式的檔案物件。對於此類物件,請改用 " +"``file.write(...)``。" #: ../../builtins/functions.rst:1643 msgid "" "Output buffering is usually determined by *file*. However, if *flush* is " "true, the stream is forcibly flushed." msgstr "" +"輸出緩衝通常會由 *file* 決定。但是如果 *flush* 為 true,則資料串流會被強制清" +"除。" #: ../../builtins/functions.rst:1647 msgid "Added the *flush* keyword argument." -msgstr "" +msgstr "增加了 *flush* 關鍵字引數。" #: ../../builtins/functions.rst:1653 msgid "Return a property attribute." -msgstr "" +msgstr "回傳 property 屬性。" #: ../../builtins/functions.rst:1655 msgid "" @@ -2320,10 +2944,12 @@ msgid "" "for setting an attribute value. *fdel* is a function for deleting an " "attribute value. And *doc* creates a docstring for the attribute." msgstr "" +"*fget* 是一個用於取得屬性值的函式,*fset* 是一個用於設定屬性值的函式,*fdel* " +"是一個用於刪除屬性值的函式,而 *doc* 會為該屬性建立一個說明字串。" #: ../../builtins/functions.rst:1659 msgid "A typical use is to define a managed attribute ``x``::" -msgstr "" +msgstr "一個典型的用途是定義一個受管理的屬性 ``x``: ::" #: ../../builtins/functions.rst:1661 msgid "" @@ -2342,12 +2968,28 @@ msgid "" "\n" " x = property(getx, setx, delx, \"I'm the 'x' property.\")" msgstr "" +"class C:\n" +" def __init__(self):\n" +" self._x = None\n" +"\n" +" def getx(self):\n" +" return self._x\n" +"\n" +" def setx(self, value):\n" +" self._x = value\n" +"\n" +" def delx(self):\n" +" del self._x\n" +"\n" +" x = property(getx, setx, delx, \"我是 'x' 屬性。\")" #: ../../builtins/functions.rst:1676 msgid "" "If *c* is an instance of *C*, ``c.x`` will invoke the getter, ``c.x = " "value`` will invoke the setter, and ``del c.x`` the deleter." msgstr "" +"如果 *c* 是 *C* 的一個實例,則 ``c.x`` 將會叫用取得器 (getter),``c.x = " +"value`` 會呼叫設定器 (setter),而 ``del c.x`` 會叫用刪除器 (deleter)。" #: ../../builtins/functions.rst:1679 msgid "" @@ -2356,6 +2998,9 @@ msgid "" "possible to create read-only properties easily using :deco:`property` as a :" "term:`decorator`::" msgstr "" +"如果有給定 *doc*,它將會是 property 屬性的說明字串。否則,property 會複製 " +"*fget* 的說明字串(如果它存在的話)。這樣一來,就能夠輕鬆地使用 :deco:" +"`property` 作為\\ :term:`裝飾器 `\\ 來建立唯讀屬性: ::" #: ../../builtins/functions.rst:1683 msgid "" @@ -2368,6 +3013,14 @@ msgid "" " \"\"\"Get the current voltage.\"\"\"\n" " return self._voltage" msgstr "" +"class Parrot:\n" +" def __init__(self):\n" +" self._voltage = 100000\n" +"\n" +" @property\n" +" def voltage(self):\n" +" \"\"\"取得目前的電壓。\"\"\"\n" +" return self._voltage" #: ../../builtins/functions.rst:1692 msgid "" @@ -2375,6 +3028,8 @@ msgid "" "\"getter\" for a read-only attribute with the same name, and it sets the " "docstring for *voltage* to \"Get the current voltage.\"" msgstr "" +"``@property`` 裝飾器將 :meth:`!voltage` 方法變成同名唯讀屬性的 \"getter\",並" +"將 *voltage* 的說明字串設成 \"Get the current voltage\"。" #: ../../builtins/functions.rst:1700 msgid "" @@ -2383,6 +3038,9 @@ msgid "" "accessor function set to the decorated function. This is best explained " "with an example:" msgstr "" +"一個屬性物件有 ``getter``、``setter`` 和 ``deleter`` 方法,這些方法可作為裝飾" +"器使用,建立一個屬性的副本,並將相應的存取函式設定為被裝飾的函式。最好用一個" +"範例來說明:" #: ../../builtins/functions.rst:1705 msgid "" @@ -2403,6 +3061,22 @@ msgid "" " def x(self):\n" " del self._x" msgstr "" +"class C:\n" +" def __init__(self):\n" +" self._x = None\n" +"\n" +" @property\n" +" def x(self):\n" +" \"\"\"我是 'x' 屬性。\"\"\"\n" +" return self._x\n" +"\n" +" @x.setter\n" +" def x(self, value):\n" +" self._x = value\n" +"\n" +" @x.deleter\n" +" def x(self):\n" +" del self._x" #: ../../builtins/functions.rst:1724 msgid "" @@ -2410,28 +3084,33 @@ msgid "" "additional functions the same name as the original property (``x`` in this " "case.)" msgstr "" +"此程式碼與第一個範例完全相等。請務必賦予附加函式與原始屬性相同的名稱(在此例" +"中為 ``x``)。" #: ../../builtins/functions.rst:1728 msgid "" "The returned property object also has the attributes ``fget``, ``fset``, and " "``fdel`` corresponding to the constructor arguments." msgstr "" +"回傳的屬性物件也有對應於建構函式引數的屬性 ``fget``、``fset`` 和 ``fdel``。" #: ../../builtins/functions.rst:1731 msgid "The docstrings of property objects are now writeable." -msgstr "" +msgstr "屬性物件的 docstrings 現在可以寫入。" #: ../../builtins/functions.rst:1736 msgid "" "Attribute holding the name of the property. The name of the property can be " "changed at runtime." -msgstr "" +msgstr "持有屬性名稱的屬性。屬性名稱可在 runtime 變更。" #: ../../builtins/functions.rst:1747 msgid "" "Rather than being a function, :class:`range` is actually an immutable " "sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`." msgstr "" +"與其說是函式,:class:`range` 實際上是一個不可變的序列型別,如 :ref:`typesseq-" +"range` 和 :ref:`typesseq` 所述。" #: ../../builtins/functions.rst:1753 msgid "" @@ -2445,10 +3124,16 @@ msgid "" "method. If :func:`sys.displayhook` is not accessible, this function will " "raise :exc:`RuntimeError`." msgstr "" +"回傳一個包含物件可列印表示的字串。對於許多型別,這個函式會嘗試回傳一個字串," +"當傳遞給 :func:`eval` 時,這個字串會產生一個具有相同值的物件;否則,這個表示" +"是一個用角括弧括起來的字串,包含物件型別的名稱,以及額外的資訊,通常包括物件" +"的名稱和位址。一個類別可以透過定義 :meth:`~object.__repr__` 方法來控制這個函" +"式對其實例的回傳值。如果 :func:`sys.displayhook` 不可存取,這個函式會引發 :" +"exc:`RuntimeError`。" #: ../../builtins/functions.rst:1764 msgid "This class has a custom representation that can be evaluated::" -msgstr "" +msgstr "這個類別有一個自訂的表示,可以被求值: ::" #: ../../builtins/functions.rst:1766 msgid "" @@ -2460,6 +3145,13 @@ msgid "" " def __repr__(self):\n" " return f\"Person('{self.name}', {self.age})\"" msgstr "" +"class Person:\n" +" def __init__(self, name, age):\n" +" self.name = name\n" +" self.age = age\n" +"\n" +" def __repr__(self):\n" +" return f\"Person('{self.name}', {self.age})\"" #: ../../builtins/functions.rst:1777 msgid "" @@ -2468,6 +3160,9 @@ msgid "" "(the :meth:`~object.__len__` method and the :meth:`~object.__getitem__` " "method with integer arguments starting at ``0``)." msgstr "" +"回傳一個反向的\\ :term:`疊代器 `。引數必須是一個擁有 :meth:" +"`~object.__reversed__` 方法或支援序列協定(即 :meth:`~object.__len__` 方法和" +"以 ``0`` 開始的整數引數的 :meth:`~object.__getitem__` 方法)的物件。" #: ../../builtins/functions.rst:1785 msgid "" @@ -2475,6 +3170,8 @@ msgid "" "*ndigits* is omitted or is ``None``, it returns the nearest integer to its " "input." msgstr "" +"回傳小數點後四捨五入到 *ndigits* 精度的 *number*。如果省略 *ndigits* 或為 " +"``None``,則會回傳最接近其輸入的整數。" #: ../../builtins/functions.rst:1789 msgid "" @@ -2486,12 +3183,18 @@ msgid "" "negative). The return value is an integer if *ndigits* is omitted or " "``None``. Otherwise, the return value has the same type as *number*." msgstr "" +"對於支援 :func:`round` 的內建型別,值會被四捨五入到最接近 10 的負 *ndigits* " +"次方的倍數;如果兩個倍數一樣接近,則會向偶數方向進位(因此,例如 " +"``round(0.5)`` 和 ``round(-0.5)`` 都是 ``0``,而 ``round(1.5)`` 是 ``2``)。" +"*ndigits* 的任何整數值都是有效的(正數、零或負數)。如果省略 *ndigits* 或為 " +"``None``,則回傳值是整數。否則回傳值與 *number* 有相同的型別。" #: ../../builtins/functions.rst:1798 msgid "" "For a general Python object ``number``, ``round`` delegates to ``number." "__round__``." msgstr "" +"對於一般的 Python 物件 ``number``,``round`` 會委派給 ``number.__round__``。" #: ../../builtins/functions.rst:1803 msgid "" @@ -2501,6 +3204,9 @@ msgid "" "represented exactly as a float. See :ref:`tut-fp-issues` for more " "information." msgstr "" +":func:`round` 對於浮點數的行為可能出乎意料:例如 ``round(2.675, 2)`` 會得到 " +"``2.67`` 而非預期的 ``2.68``。這不是一個 bug:這是因為大多數十進位小數無法精" +"確地表示為浮點數。更多資訊請參閱 :ref:`tut-fp-issues`。" #: ../../builtins/functions.rst:1814 msgid "" @@ -2508,6 +3214,8 @@ msgid "" "*iterable*. :class:`set` is a built-in class. See also :ref:`types-set` " "for documentation about this class." msgstr "" +"回傳一個新的 :class:`set` 物件,可選擇性地包含從 *iterable* 取得的元素。:" +"class:`set` 是一個內建類別。關於此類別的說明文件亦請參閱 :ref:`types-set`。" #: ../../builtins/functions.rst:1818 msgid "" @@ -2515,6 +3223,8 @@ msgid "" "class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` " "module." msgstr "" +"關於其他容器,請參閱內建的 :class:`frozenset`、:class:`list`、:class:`tuple` " +"和 :class:`dict` 類別,以及 :mod:`collections` 模組。" #: ../../builtins/functions.rst:1825 msgid "" @@ -2524,6 +3234,9 @@ msgid "" "provided the object allows it. For example, ``setattr(x, 'foobar', 123)`` " "is equivalent to ``x.foobar = 123``." msgstr "" +"這是 :func:`getattr` 的對應函式。引數是一個物件、一個字串和一個任意值。該字串" +"可以指定一個現有屬性或一個新的屬性。此函式會將值賦予該屬性,前提是該物件允許" +"這麼做。例如 ``setattr(x, 'foobar', 123)`` 等效於 ``x.foobar = 123``。" #: ../../builtins/functions.rst:1831 msgid "" @@ -2533,6 +3246,10 @@ msgid "" "whose name is not an identifier will not be accessible using the dot " "notation, but is accessible through :func:`getattr` etc.." msgstr "" +"*name* 不必是 :ref:`identifiers` 中定義的 Python 識別字,除非該物件選擇強制要" +"求,例如在自訂的 :meth:`~object.__getattribute__` 中或透過 :attr:`~object." +"__slots__`。名稱不是識別字的屬性將無法使用點記法存取,但可以透過 :func:" +"`getattr` 等方式存取。" #: ../../builtins/functions.rst:1839 msgid "" @@ -2540,6 +3257,9 @@ msgid "" "compilation time, one must manually mangle a private attribute's (attributes " "with two leading underscores) name in order to set it with :func:`setattr`." msgstr "" +"由於\\ :ref:`私有名稱修飾 `\\ 發生在編譯期間,若要使" +"用 :func:`setattr` 設定私有屬性(名稱以兩個底線開頭的屬性),必須手動修飾其名" +"稱。" #: ../../builtins/functions.rst:1848 msgid "" @@ -2547,18 +3267,24 @@ msgid "" "``range(start, stop, step)``. The *start* and *step* arguments default to " "``None``." msgstr "" +"回傳一個 :term:`slice` 物件,表示由 ``range(start, stop, step)`` 指定的索引集" +"合。*start* 和 *step* 引數預設為 ``None``。" #: ../../builtins/functions.rst:1852 msgid "" "Slice objects are also generated when :ref:`slicing syntax ` is " "used. For example: ``a[start:stop:step]`` or ``a[start:stop, i]``." msgstr "" +"Slice 物件也會在使用\\ :ref:`切片語法 `\\ 時產生。例如:``a[start:" +"stop:step]`` 或 ``a[start:stop, i]``。" #: ../../builtins/functions.rst:1855 msgid "" "See :func:`itertools.islice` for an alternate version that returns an :term:" "`iterator`." msgstr "" +"請參閱 :func:`itertools.islice` 以取得回傳\\ :term:`疊代器 `\\ 的替" +"代版本。" #: ../../builtins/functions.rst:1862 msgid "" @@ -2566,21 +3292,25 @@ msgid "" "default). They have no other explicit functionality; however, they are used " "by NumPy and other third-party packages." msgstr "" +"這些唯讀屬性被設定為引數值(或其預設值)。它們沒有其他明確的功能;然而,它們" +"會被 NumPy 和其他第三方套件使用。" #: ../../builtins/functions.rst:1866 msgid "" "Slice objects are now :term:`hashable` (provided :attr:`~slice.start`, :attr:" "`~slice.stop`, and :attr:`~slice.step` are hashable)." msgstr "" +"Slice 物件現在是\\ :term:`可雜湊的 `\\(前提是 :attr:`~slice." +"start`、:attr:`~slice.stop` 和 :attr:`~slice.step` 都是可雜湊的)。" #: ../../builtins/functions.rst:1872 msgid "Return a new sorted list from the items in *iterable*." -msgstr "" +msgstr "從 *iterable* 中的項目回傳一個新的已排序 list。" #: ../../builtins/functions.rst:1874 msgid "" "Has two optional arguments which must be specified as keyword arguments." -msgstr "" +msgstr "有兩個選擇性引數,只能使用關鍵字引數來指定。" #: ../../builtins/functions.rst:1876 msgid "" @@ -2588,18 +3318,23 @@ msgid "" "comparison key from each element in *iterable* (for example, ``key=str." "lower``). The default value is ``None`` (compare the elements directly)." msgstr "" +"*key* 指定一個具有一個引數的函式,用於從 *iterable* 中的每個元素提取比較鍵" +"(例如 ``key=str.lower``)。預設值為 ``None``\\(直接比較元素)。" #: ../../builtins/functions.rst:1880 msgid "" "*reverse* is a boolean value. If set to ``True``, then the list elements " "are sorted as if each comparison were reversed." msgstr "" +"*reverse* 是一個布林值。如果設為 ``True``,則 list 元素的排序方式如同每次比較" +"都被反轉一樣。" #: ../../builtins/functions.rst:1883 msgid "" "Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a " "*key* function." msgstr "" +"使用 :func:`functools.cmp_to_key` 將舊式的 *cmp* 函式轉換為 *key* 函式。" #: ../../builtins/functions.rst:1886 msgid "" @@ -2608,6 +3343,9 @@ msgid "" "compare equal --- this is helpful for sorting in multiple passes (for " "example, sort by department, then by salary grade)." msgstr "" +"內建的 :func:`sorted` 函式保證是穩定排序。一個排序如果保證不會改變比較結果相" +"等的元素之間的相對順序,就是穩定的 --- 這對於多次排序很有幫助(例如,先按部門" +"排序,再按薪資等級排序)。" #: ../../builtins/functions.rst:1891 msgid "" @@ -2620,21 +3358,27 @@ msgid "" "mixed type comparisons which can call the reflected :meth:`~object.__gt__` " "method." msgstr "" +"排序演算法僅使用項目之間的 ``<`` 比較。雖然定義 :meth:`~object.__lt__` 方法就" +"足以進行排序,但 :PEP:`8` 建議實作全部六個\\ :ref:`複合比較 `。" +"這有助於避免在使用相同資料搭配其他排序工具(例如依賴不同底層方法的 :func:" +"`max`)時產生錯誤。實作全部六個比較也有助於避免混合型別比較時的混淆,因為這種" +"比較可能會呼叫被反映的 :meth:`~object.__gt__` 方法。" #: ../../builtins/functions.rst:1900 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." -msgstr "" +msgstr "有關排序的範例和簡要的排序教學,請參閱 :ref:`sortinghowto`。" #: ../../builtins/functions.rst:1904 msgid "Transform a method into a static method." -msgstr "" +msgstr "將一個方法轉換為靜態方法 (static method)。" #: ../../builtins/functions.rst:1906 msgid "" "A static method does not receive an implicit first argument. To declare a " "static method, use this idiom::" msgstr "" +"靜態方法不會接收隱含的第一個引數。要宣告一個靜態方法,請使用以下慣用寫法: ::" #: ../../builtins/functions.rst:1909 msgid "" @@ -2642,12 +3386,17 @@ msgid "" " @staticmethod\n" " def f(arg1, arg2, argN): ..." msgstr "" +"class C:\n" +" @staticmethod\n" +" def f(arg1, arg2, argN): ..." #: ../../builtins/functions.rst:1913 msgid "" "The ``@staticmethod`` form is a function :term:`decorator` -- see :ref:" "`function` for details." msgstr "" +"``@staticmethod`` 語法是一個函式 :term:`decorator` - 參見 :ref:`function` 中" +"的詳細介紹。" #: ../../builtins/functions.rst:1916 msgid "" @@ -2656,6 +3405,9 @@ msgid "" "`descriptor` is also callable, so it can be used in the class definition " "(such as ``f()``)." msgstr "" +"靜態方法可以在類別上呼叫(例如 ``C.f()``),也可以在實例上呼叫(例如 ``C()." +"f()``)。此外,靜態方法的\\ :term:`描述器 `\\ 也是可呼叫的,因此" +"可以在類別定義中使用(例如 ``f()``)。" #: ../../builtins/functions.rst:1921 msgid "" @@ -2663,6 +3415,8 @@ msgid "" "see :deco:`classmethod` for a variant that is useful for creating alternate " "class constructors." msgstr "" +"Python 中的靜態方法類似於 Java 或 C++ 中的靜態方法。另請參閱 :deco:" +"`classmethod`,它是一個對於建立替代類別建構式很有用的變體。" #: ../../builtins/functions.rst:1925 msgid "" @@ -2672,6 +3426,9 @@ msgid "" "want to avoid the automatic transformation to instance method. For these " "cases, use this idiom::" msgstr "" +"如同所有裝飾器,也可以將 ``staticmethod`` 作為一般函式呼叫並對其結果進行操" +"作。這在某些情況下是必要的,例如當你需要從類別主體中引用一個函式,且希望避免" +"自動轉換為實例方法時。對於這些情況,請使用以下慣用寫法: ::" #: ../../builtins/functions.rst:1931 msgid "" @@ -2681,10 +3438,15 @@ msgid "" "class C:\n" " method = staticmethod(regular_function)" msgstr "" +"def regular_function():\n" +" ...\n" +"\n" +"class C:\n" +" method = staticmethod(regular_function)" #: ../../builtins/functions.rst:1937 msgid "For more information on static methods, see :ref:`types`." -msgstr "" +msgstr "關於 static method 的更多資訊,請參考 :ref:`types`。" #: ../../builtins/functions.rst:1939 msgid "" @@ -2693,17 +3455,23 @@ msgid "" "attr:`~function.__doc__` and :attr:`~function.__annotations__`), have a new " "``__wrapped__`` attribute, and are now callable as regular functions." msgstr "" +"Static method 現在繼承了 method 屬性(:attr:`~function.__module__`、:attr:" +"`~function.__name__`、:attr:`~function.__qualname__`、:attr:`~function." +"__doc__` 和 :attr:`~function.__annotations__`),並擁有一個新的 " +"``__wrapped__`` 屬性,且為如一般函式的可呼叫物件。" #: ../../builtins/functions.rst:1957 msgid "" "Return a :class:`str` version of *object*. See :func:`str` for details." -msgstr "" +msgstr "回傳 *object* 的 :class:`str` 版本。詳細資訊請參閱 :func:`str`。" #: ../../builtins/functions.rst:1959 msgid "" "``str`` is the built-in string :term:`class`. For general information about " "strings, see :ref:`textseq`." msgstr "" +"``str`` 是內建的字串\\ :term:`類別 `。有關字串的一般資訊,請參閱 :ref:" +"`textseq`。" #: ../../builtins/functions.rst:1965 msgid "" @@ -2711,6 +3479,8 @@ msgid "" "the total. The *iterable*'s items are normally numbers, and the start value " "is not allowed to be a string." msgstr "" +"從左到右加總 *start* 和一個 *iterable* 的項目並回傳總和。*iterable* 的項目通" +"常是數字,且 start 值不允許為字串。" #: ../../builtins/functions.rst:1969 msgid "" @@ -2720,22 +3490,26 @@ msgid "" "see :func:`math.fsum`\\. To concatenate a series of iterables, consider " "using :func:`itertools.chain`." msgstr "" +"對於某些使用情境,有比 :func:`sum` 更好的替代方案。串接字串序列的首選快速方式" +"是呼叫 ``''.join(sequence)``。要以延伸精度加總浮點數值,請參閱 :func:`math." +"fsum`。要串接一系列可疊代物件,請考慮使用 :func:`itertools.chain`。" #: ../../builtins/functions.rst:1975 msgid "The *start* parameter can be specified as a keyword argument." -msgstr "" +msgstr "*start* 參數可被指定為關鍵字引數。" #: ../../builtins/functions.rst:1978 msgid "" "Summation of floats switched to an algorithm that gives higher accuracy and " "better commutativity on most builds." msgstr "" +"浮點數的加總已切換到一個在大多數建置上提供更高精確度和更好交換律的演算法。" #: ../../builtins/functions.rst:1981 msgid "" "Added specialization for summation of complexes, using same algorithm as for " "summation of floats." -msgstr "" +msgstr "新增了複數加總的特化處理,使用與浮點數加總相同的演算法。" #: ../../builtins/functions.rst:1989 msgid "" @@ -2743,12 +3517,16 @@ msgid "" "class of *type*. This is useful for accessing inherited methods that have " "been overridden in a class." msgstr "" +"回傳一個代理物件,該物件會將方法呼叫委派給 *type* 的父類別或兄弟類別。這對於" +"存取在類別中被覆寫的繼承方法很有用。" #: ../../builtins/functions.rst:1993 msgid "" "The *object_or_type* determines the :term:`method resolution order` to be " "searched. The search starts from the class right after the *type*." msgstr "" +"*object_or_type* 決定了要搜尋的\\ :term:`方法解析順序 `。搜尋從 *type* 之後的類別開始。" #: ../../builtins/functions.rst:1997 msgid "" @@ -2756,6 +3534,9 @@ msgid "" "> A -> object`` and the value of *type* is ``B``, then :func:`super` " "searches ``C -> A -> object``." msgstr "" +"舉例來說,如果 *object_or_type* 的 :attr:`~type.__mro__` 是 ``D -> B -> C -> " +"A -> object``,且 *type* 的值是 ``B``,則 :func:`super` 會搜尋 ``C -> A -> " +"object``。" #: ../../builtins/functions.rst:2001 msgid "" @@ -2764,6 +3545,9 @@ msgid "" "`getattr` and :func:`super`. The attribute is dynamic and can change " "whenever the inheritance hierarchy is updated." msgstr "" +"與 *object_or_type* 對應的類別之 :attr:`~type.__mro__` 屬性列出了 :func:" +"`getattr` 和 :func:`super` 所使用的方法解析搜尋順序。該屬性是動態的,每當繼承" +"階層被更新時就可能改變。" #: ../../builtins/functions.rst:2006 msgid "" @@ -2772,6 +3556,9 @@ msgid "" "If the second argument is a type, ``issubclass(type2, type)`` must be true " "(this is useful for classmethods)." msgstr "" +"如果省略第二個引數,回傳的 super 物件就是未繫結的。如果第二個引數是一個物件," +"``isinstance(obj, type)`` 必須為真。如果第二個引數是一個型別," +"``issubclass(type2, type)`` 必須為真(這對類別方法很有用)。" #: ../../builtins/functions.rst:2011 msgid "" @@ -2782,6 +3569,10 @@ msgid "" "argument :func:`!super` will not work as expected within nested functions, " "including generator expressions, which implicitly create nested functions.)" msgstr "" +"在類別的一般方法中直接呼叫時,兩個引數都可以省略(「零引數 :func:`!" +"super`」)。在這種情況下,*type* 將是外圍類別,而 *obj* 將是直接外圍函式的第" +"一個引數(通常是 ``self``)。(這意味著零引數 :func:`!super` 在巢狀函式中將無" +"法如預期般運作,包括隱式建立巢狀函式的產生器運算式。)" #: ../../builtins/functions.rst:2018 msgid "" @@ -2790,6 +3581,9 @@ msgid "" "naming them explicitly, thus making the code more maintainable. This use " "closely parallels the use of *super* in other programming languages." msgstr "" +"*super* 有兩種典型的使用情境。在具有單一繼承的類別階層中,*super* 可以用來參" +"照父類別而不需要明確命名它們,從而使程式碼更易於維護。這種用法與 *super* 在其" +"他程式語言中的用法非常相似。" #: ../../builtins/functions.rst:2023 msgid "" @@ -2803,10 +3597,15 @@ msgid "" "changes in the class hierarchy, and because that order can include sibling " "classes that are unknown prior to runtime)." msgstr "" +"第二種使用情境是在動態執行環境中支援協作式多重繼承。這種使用情境是 Python 獨" +"有的,在靜態編譯語言或僅支援單一繼承的語言中找不到。這使得實作「鑽石圖」" +"(diamond diagrams)成為可能,其中多個基礎類別實作相同的方法。良好的設計要求" +"這些實作在每種情況下都有相同的呼叫簽名(因為呼叫順序是在執行期決定的,因為該" +"順序會適應類別階層的變化,也因為該順序可以包含在執行期之前未知的兄弟類別)。" #: ../../builtins/functions.rst:2033 msgid "For both use cases, a typical superclass call looks like this::" -msgstr "" +msgstr "對於這兩種使用情境,一個典型的超類別呼叫如下: ::" #: ../../builtins/functions.rst:2035 msgid "" @@ -2815,6 +3614,10 @@ msgid "" " super().method(arg) # This does the same thing as:\n" " # super(C, self).method(arg)" msgstr "" +"class C(B):\n" +" def method(self, arg):\n" +" super().method(arg) # 這和以下做法相同:\n" +" # super(C, self).method(arg)" #: ../../builtins/functions.rst:2040 msgid "" @@ -2822,6 +3625,8 @@ msgid "" "lookups. One possible use case for this is calling :term:`descriptors " "` in a parent or sibling class." msgstr "" +"除了方法查找之外,:func:`super` 也適用於屬性查找。這個功能的一個可能使用情境" +"是在父類別或兄弟類別中呼叫\\ :term:`描述器 `。" #: ../../builtins/functions.rst:2044 msgid "" @@ -2832,6 +3637,11 @@ msgid "" "inheritance. Accordingly, :func:`super` is undefined for implicit lookups " "using statements or operators such as ``super()[name]``." msgstr "" +"請注意,:func:`super` 是作為顯式點號屬性查找(例如 ``super()." +"__getitem__(name)``)之繫結過程的一部分來實作的。它透過實作自己的 :meth:" +"`~object.__getattribute__` 方法來搜尋類別,以可預測的順序來支援協作式多重繼" +"承。因此,:func:`super` 對於使用陳述式或運算子的隱式查找(例如 ``super()" +"[name]``)是未定義的。" #: ../../builtins/functions.rst:2052 msgid "" @@ -2842,6 +3652,10 @@ msgid "" "necessary details to correctly retrieve the class being defined, as well as " "accessing the current instance for ordinary methods." msgstr "" +"另外請注意,除了零引數形式之外,:func:`super` 並不限於在方法內部使用。雙引數" +"形式會精確地指定引數並建立適當的參照。零引數形式只能在類別定義內部使用,因為" +"編譯器會填入必要的細節以正確地取得正在被定義的類別,以及存取一般方法的目前實" +"例。" #: ../../builtins/functions.rst:2059 msgid "" @@ -2849,18 +3663,25 @@ msgid "" "`super`, see `guide to using super() `_." msgstr "" +"有關如何使用 :func:`super` 設計協作式類別的實用建議,請參閱\\ `使用 super() " +"的指南 `_。" #: ../../builtins/functions.rst:2063 msgid "" ":class:`super` objects are now :mod:`pickleable ` and :mod:" "`copyable `." msgstr "" +":class:`super` 物件現在可以使用 :mod:`pickle ` 序列化以及使用 :mod:" +"`copy ` 複製。" #: ../../builtins/functions.rst:2072 msgid "" "Rather than being a function, :class:`tuple` is actually an immutable " "sequence type, as documented in :ref:`typesseq-tuple` and :ref:`typesseq`." msgstr "" +":class:`tuple` 實際上不是一個函式,而是一個不可變的序列型別,如 :ref:" +"`typesseq-tuple` 和 :ref:`typesseq` 中所述。" #: ../../builtins/functions.rst:2081 msgid "" @@ -2868,12 +3689,16 @@ msgid "" "type object and generally the same object as returned by :attr:`object." "__class__`." msgstr "" +"傳入一個引數時,回傳一個 *object* 的型別。回傳值是一個型別物件,通常與 :attr:" +"`object.__class__` 所回傳的物件相同。" #: ../../builtins/functions.rst:2085 msgid "" "The :func:`isinstance` built-in function is recommended for testing the type " "of an object, because it takes subclasses into account." msgstr "" +"建議使用內建函式 :func:`isinstance` 來測試物件的型別,因為它會將子類別納入考" +"量。" #: ../../builtins/functions.rst:2088 msgid "" @@ -2887,20 +3712,26 @@ msgid "" "__dict__` attribute. The following two statements create identical :class:`!" "type` objects:" msgstr "" +"傳入三個引數時,回傳一個新的型別物件。這本質上是 :keyword:`class` 陳述式的動" +"態形式。*name* 字串是類別名稱,會成為 :attr:`~type.__name__` 屬性。*bases* " +"tuple 包含基底類別,會成為 :attr:`~type.__bases__` 屬性;如果為空,則會加入所" +"有類別的最終基底類別 :class:`object`。*dict* 字典包含類別主體的屬性和方法定" +"義;它可能會被複製或包裝後才成為 :attr:`~type.__dict__` 屬性。以下兩個陳述式" +"會建立相同的 :class:`!type` 物件:" #: ../../builtins/functions.rst:2103 msgid "See also:" -msgstr "" +msgstr "另請參閱:" #: ../../builtins/functions.rst:2105 msgid "" ":ref:`Documentation on attributes and methods on classes `." -msgstr "" +msgstr ":ref:`類別的屬性和方法的文件 `。" #: ../../builtins/functions.rst:2106 msgid ":ref:`bltin-type-objects`" -msgstr "" +msgstr ":ref:`bltin-type-objects`" #: ../../builtins/functions.rst:2108 msgid "" @@ -2909,6 +3740,9 @@ msgid "" "in the same way that keywords in a class definition (besides *metaclass*) " "would." msgstr "" +"提供給三引數形式的關鍵字引數會以與類別定義中的關鍵字(除了 *metaclass* 之外)" +"相同的方式,傳遞給適當的元類別機制(通常是 :meth:`~object." +"__init_subclass__`)。" #: ../../builtins/functions.rst:2113 msgid "" @@ -2916,22 +3750,29 @@ msgid "" "the metaclass ``__prepare__`` method (see :ref:`prepare`). Use :func:`types." "new_class` to dynamically create a class using the appropriate metaclass." msgstr "" +"與 :keyword:`class` 陳述式不同,三引數形式不會呼叫元類別的 ``__prepare__`` 方" +"法(見 :ref:`prepare`)。請使用 :func:`types.new_class` 以適當的元類別動態建" +"立類別。" #: ../../builtins/functions.rst:2118 msgid "See also :ref:`class-customization`." -msgstr "" +msgstr "另請參閱 :ref:`class-customization`。" #: ../../builtins/functions.rst:2120 msgid "" "Subclasses of :class:`!type` which don't override ``type.__new__`` may no " "longer use the one-argument form to get the type of an object." msgstr "" +"沒有覆寫 ``type.__new__`` 的 :class:`!type` 子類別不能再使用單引數形式來取得" +"物件的型別。" #: ../../builtins/functions.rst:2127 msgid "" "Return the :attr:`~object.__dict__` attribute for a module, class, instance, " "or any other object with a :attr:`!__dict__` attribute." msgstr "" +"回傳模組、類別、實例或任何其他具有 :attr:`!__dict__` 屬性的物件的 :attr:" +"`~object.__dict__` 屬性。" #: ../../builtins/functions.rst:2130 msgid "" @@ -2940,10 +3781,13 @@ msgid "" "their :attr:`!__dict__` attributes (for example, classes use a :class:`types." "MappingProxyType` to prevent direct dictionary updates)." msgstr "" +"像模組和實例這樣的物件具有可更新的 :attr:`~object.__dict__` 屬性;然而,其他" +"物件的 :attr:`!__dict__` 屬性可能有寫入限制(例如,類別使用 :class:`types." +"MappingProxyType` 來防止直接更新字典)。" #: ../../builtins/functions.rst:2135 msgid "Without an argument, :func:`vars` acts like :func:`locals`." -msgstr "" +msgstr "不帶引數時,:func:`vars` 的行為與 :func:`locals` 相同。" #: ../../builtins/functions.rst:2137 msgid "" @@ -2951,22 +3795,24 @@ msgid "" "doesn't have a :attr:`~object.__dict__` attribute (for example, if its class " "defines the :attr:`~object.__slots__` attribute)." msgstr "" +"如果指定了一個物件但它沒有 :attr:`~object.__dict__` 屬性(例如,如果它的類別" +"定義了 :attr:`~object.__slots__` 屬性),則會引發 :exc:`TypeError` 例外。" #: ../../builtins/functions.rst:2143 msgid "" "The result of calling this function without an argument has been updated as " "described for the :func:`locals` builtin." -msgstr "" +msgstr "不帶引數呼叫此函式的結果已按照內建函式 :func:`locals` 的說明進行更新。" #: ../../builtins/functions.rst:2149 msgid "" "Iterate over several iterables in parallel, producing tuples with an item " "from each one." -msgstr "" +msgstr "平行疊代多個可疊代物件,產生包含每個可疊代物件中一個項目的 tuple。" #: ../../builtins/functions.rst:2152 msgid "Example::" -msgstr "" +msgstr "例如: ::" #: ../../builtins/functions.rst:2154 msgid "" @@ -2977,12 +3823,20 @@ msgid "" "(2, 'spice')\n" "(3, 'everything nice')" msgstr "" +">>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):\n" +"... print(item)\n" +"...\n" +"(1, 'sugar')\n" +"(2, 'spice')\n" +"(3, 'everything nice')" #: ../../builtins/functions.rst:2161 msgid "" "More formally: :func:`zip` returns an iterator of tuples, where the *i*-th " "tuple contains the *i*-th element from each of the argument iterables." msgstr "" +"更正式地說::func:`zip` 回傳一個由 tuple 組成的疊代器,其中第 *i* 個 tuple 包" +"含來自每個引數可疊代物件的第 *i* 個元素。" #: ../../builtins/functions.rst:2164 msgid "" @@ -2990,6 +3844,8 @@ msgid "" "columns into rows. This is similar to `transposing a matrix `_." msgstr "" +"另一種理解 :func:`zip` 的方式是它將列(row)轉換為行(column),將行轉換為" +"列。這類似於\\ `轉置矩陣 `_。" #: ../../builtins/functions.rst:2168 msgid "" @@ -2997,6 +3853,8 @@ msgid "" "iterated on, e.g. by a :keyword:`!for` loop or by wrapping in a :class:" "`list`." msgstr "" +":func:`zip` 是惰性的 (lazy):元素在可疊代物件被疊代之前不會被處理,例如透過一" +"個 :keyword:`!for` 迴圈或包裝在一個 :class:`list` 中。" #: ../../builtins/functions.rst:2172 msgid "" @@ -3005,6 +3863,9 @@ msgid "" "the code that prepared these iterables. Python offers three different " "approaches to dealing with this issue:" msgstr "" +"需要考慮的一點是,傳遞給 :func:`zip` 的可疊代物件可能具有不同的長度;有時候是" +"刻意設計的,有時候是因為準備這些可疊代物件的程式碼中的錯誤。Python 提供三種不" +"同的方式來處理這個問題:" #: ../../builtins/functions.rst:2177 msgid "" @@ -3012,12 +3873,17 @@ msgid "" "`exhausted`. It will ignore the remaining items in the longer iterables, " "cutting off the result to the length of the shortest iterable::" msgstr "" +"預設情況下,:func:`zip` 會在最短的可疊代物件\\ :term:`耗盡 `\\ 時" +"停止。它會忽略較長可疊代物件中的剩餘項目,將結果截斷到最短可疊代物件的長" +"度: ::" #: ../../builtins/functions.rst:2181 msgid "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" msgstr "" +">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" +"[(0, 'fee'), (1, 'fi'), (2, 'fo')]" #: ../../builtins/functions.rst:2184 msgid "" @@ -3025,18 +3891,24 @@ msgid "" "equal length. In such cases, it's recommended to use the ``strict=True`` " "option. Its output is the same as regular :func:`zip`::" msgstr "" +":func:`zip` 常常用於可疊代物件被假設等長的情況。在這種情況下,建議使用 " +"``strict=True`` 選項。它的輸出與一般的 :func:`zip` 相同: ::" #: ../../builtins/functions.rst:2188 msgid "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" msgstr "" +">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" +"[('a', 1), ('b', 2), ('c', 3)]" #: ../../builtins/functions.rst:2191 msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is :term:`exhausted` before the others:" msgstr "" +"與預設行為不同的是,如果有一個可疊代物件先於其他可疊代物件\\ :term:`耗盡 " +"`,它會引發 :exc:`ValueError`:" #: ../../builtins/functions.rst:2209 msgid "" @@ -3044,6 +3916,8 @@ msgid "" "different lengths will be silenced, possibly manifesting as a hard-to-find " "bug in another part of the program." msgstr "" +"如果沒有 ``strict=True`` 引數,任何導致可疊代物件長度不同的 bug 都會被隱藏," +"可能會在程式的其他部分表現為難以發現的 bug。" #: ../../builtins/functions.rst:2213 msgid "" @@ -3051,16 +3925,20 @@ msgid "" "iterables have the same length. This is done by :func:`itertools." "zip_longest`." msgstr "" +"較短的可疊代物件可以填充常數值,使所有可疊代物件的長度相同。這可以透過 :func:" +"`itertools.zip_longest` 來完成。" #: ../../builtins/functions.rst:2217 msgid "" "Edge cases: With a single iterable argument, :func:`zip` returns an iterator " "of 1-tuples. With no arguments, it returns an empty iterator." msgstr "" +"邊界情況:對於單一可疊代引數,:func:`zip` 會回傳一個 1-tuple 的疊代器。如果沒" +"有引數,它會回傳一個空的疊代器。" #: ../../builtins/functions.rst:2220 msgid "Tips and tricks:" -msgstr "" +msgstr "秘訣與技巧:" #: ../../builtins/functions.rst:2222 msgid "" @@ -3070,12 +3948,16 @@ msgid "" "``n`` times so that each output tuple has the result of ``n`` calls to the " "iterator. This has the effect of dividing the input into n-length chunks." msgstr "" +"可疊代物件的從左至右求值順序是有保證的。這使得使用 ``zip(*[iter(s)]*n, " +"strict=True)`` 將資料序列聚類為 n 個長度群組的慣用語成為可能。這會重複\\ *相" +"同的*\\ 疊代器 ``n`` 次,因此每個輸出 tuple 會有 ``n`` 次呼叫疊代器的結果。這" +"樣做的效果是將輸入分割成 n 個長度的區塊。" #: ../../builtins/functions.rst:2228 msgid "" ":func:`zip` in conjunction with the ``*`` operator can be used to unzip a " "list::" -msgstr "" +msgstr ":func:`zip` 與 ``*`` 運算子結合可以用來解壓縮 (unzip) 一個 list: ::" #: ../../builtins/functions.rst:2231 msgid "" @@ -3087,16 +3969,25 @@ msgid "" ">>> x == list(x2) and y == list(y2)\n" "True" msgstr "" +">>> x = [1, 2, 3]\n" +">>> y = [4, 5, 6]\n" +">>> list(zip(x, y))\n" +"[(1, 4), (2, 5), (3, 6)]\n" +">>> x2, y2 = zip(*zip(x, y))\n" +">>> x == list(x2) and y == list(y2)\n" +"True" #: ../../builtins/functions.rst:2239 msgid "Added the ``strict`` argument." -msgstr "" +msgstr "增加了 ``strict`` 引數。" #: ../../builtins/functions.rst:2251 msgid "" "This is an advanced function that is not needed in everyday Python " "programming, unlike :func:`importlib.import_module`." msgstr "" +"這是一個進階的函式,不像 :func:`importlib.import_module`,這在日常 Python 程" +"式設計中並不需要。" #: ../../builtins/functions.rst:2254 msgid "" @@ -3109,6 +4000,12 @@ msgid "" "implementation is in use. Direct use of :func:`__import__` is also " "discouraged in favor of :func:`importlib.import_module`." msgstr "" +"這個函式被 :keyword:`import` 陳述式所叫用。它可以被取代(透過引入 :mod:" +"`builtins` 模組並指定給 ``builtins.__import__``),以改變 :keyword:`!import` " +"陳述式的語意,但這樣做是\\ **強烈**\\ 不鼓勵的,因為通常使用 import 鉤子" +"(見 :pep:`302`)來達到相同的目的會比較簡單,而且也不會造成假設使用預設 " +"import 實作的程式碼問題。我們也不鼓勵直接使用 :func:`__import__`,而應改用 :" +"func:`importlib.import_module`。" #: ../../builtins/functions.rst:2263 msgid "" @@ -3119,6 +4016,10 @@ msgid "" "does not use its *locals* argument at all and uses its *globals* only to " "determine the package context of the :keyword:`import` statement." msgstr "" +"這個函式引入 *name* 模組,可能會使用給定的 *globals* 和 *locals* 來決定如何在" +"套件情境中解釋這個名稱。*fromlist* 給出應該從 *name* 給出的模組引入的物件或子" +"模組的名稱。標準的實作完全不使用 *locals* 引數,而只使用 *globals* 來決定 :" +"keyword:`import` 陳述式的套件情境。" #: ../../builtins/functions.rst:2270 msgid "" @@ -3128,6 +4029,9 @@ msgid "" "directory of the module calling :func:`__import__` (see :pep:`328` for the " "details)." msgstr "" +"*level* 指定使用絕對或相對引入。``0``\\(預設)表示只執行絕對引入。*level* 的" +"正值表示相對於呼叫 :func:`__import__` 的模組目錄要搜尋的父目錄數目(參見 :" +"pep:`328` 以了解詳情)。" #: ../../builtins/functions.rst:2276 msgid "" @@ -3136,36 +4040,43 @@ msgid "" "module named by *name*. However, when a non-empty *fromlist* argument is " "given, the module named by *name* is returned." msgstr "" +"當 *name* 變數的形式是 ``package.module`` 時,通常會回傳最上層的套件(直到第" +"一個點為止的名稱),而\\ *不是* *name* 所命名的模組。然而,當給予一個非空的 " +"*fromlist* 引數時,會回傳以 *name* 命名的模組。" #: ../../builtins/functions.rst:2281 msgid "" "For example, the statement ``import spam`` results in bytecode resembling " "the following code::" msgstr "" +"例如,陳述式 ``import spam`` 會產生類似以下程式碼的位元組碼 (bytecode): ::" #: ../../builtins/functions.rst:2284 msgid "spam = __import__('spam', globals(), locals(), [], 0)" -msgstr "" +msgstr "spam = __import__('spam', globals(), locals(), [], 0)" #: ../../builtins/functions.rst:2286 msgid "The statement ``import spam.ham`` results in this call::" -msgstr "" +msgstr "陳述式 ``import spam.ham`` 的結果是這樣的呼叫: ::" #: ../../builtins/functions.rst:2288 msgid "spam = __import__('spam.ham', globals(), locals(), [], 0)" -msgstr "" +msgstr "spam = __import__('spam.ham', globals(), locals(), [], 0)" #: ../../builtins/functions.rst:2290 msgid "" "Note how :func:`__import__` returns the toplevel module here because this is " "the object that is bound to a name by the :keyword:`import` statement." msgstr "" +"請注意 :func:`__import__` 在這裡如何回傳頂層模組(toplevel module),因為這是" +"由 :keyword:`import` 陳述式綁定名稱的物件。" #: ../../builtins/functions.rst:2293 msgid "" "On the other hand, the statement ``from spam.ham import eggs, sausage as " "saus`` results in ::" msgstr "" +"另一方面,陳述式 ``from spam.ham import eggs, sausage as saus`` 結果是: ::" #: ../../builtins/functions.rst:2296 msgid "" @@ -3173,6 +4084,9 @@ msgid "" "eggs = _temp.eggs\n" "saus = _temp.sausage" msgstr "" +"_temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], 0)\n" +"eggs = _temp.eggs\n" +"saus = _temp.sausage" #: ../../builtins/functions.rst:2300 msgid "" @@ -3180,28 +4094,34 @@ msgid "" "this object, the names to import are retrieved and assigned to their " "respective names." msgstr "" +"這裡,``spam.ham`` 模組會從 :func:`__import__` 回傳。從這個物件中,要引入的名" +"稱會被擷取並指定給它們各自的名稱。" #: ../../builtins/functions.rst:2304 msgid "" "If you simply want to import a module (potentially within a package) by " "name, use :func:`importlib.import_module`." msgstr "" +"如果你只想依名稱引入一個模組(可能在套件中),請使用 :func:`importlib." +"import_module`。" #: ../../builtins/functions.rst:2307 msgid "" "Negative values for *level* are no longer supported (which also changes the " "default value to 0)." -msgstr "" +msgstr "不再支援 *level* 的負值(這也將預設值變為 0)。" #: ../../builtins/functions.rst:2311 msgid "" "When the command line options :option:`-E` or :option:`-I` are being used, " "the environment variable :envvar:`PYTHONCASEOK` is now ignored." msgstr "" +"當使用命令列選項 :option:`-E` 或 :option:`-I` 時,環境變數 :envvar:" +"`PYTHONCASEOK` 現在會被忽略。" #: ../../builtins/functions.rst:2316 msgid "Footnotes" -msgstr "" +msgstr "註腳" #: ../../builtins/functions.rst:2317 msgid "" @@ -3209,111 +4129,113 @@ msgid "" "you are reading the code from a file, make sure to use newline conversion " "mode to convert Windows or Mac-style newlines." msgstr "" +"剖析器只接受 Unix 風格的行結束符。如果你從檔案中讀取程式碼,請確保用換行符號" +"轉換模式轉換 Windows 或 Mac 風格的換行符號。" #: ../../builtins/functions.rst:156 msgid "Boolean" -msgstr "" +msgstr "Boolean(布林值)" #: ../../builtins/functions.rst:156 ../../builtins/functions.rst:2079 msgid "type" -msgstr "" +msgstr "type(型別)" #: ../../builtins/functions.rst:659 msgid "built-in function" -msgstr "" +msgstr "built-in function(內建函式)" #: ../../builtins/functions.rst:659 msgid "exec" -msgstr "" +msgstr "exec" #: ../../builtins/functions.rst:758 msgid "NaN" -msgstr "" +msgstr "NaN" #: ../../builtins/functions.rst:758 msgid "Infinity" -msgstr "" +msgstr "Infinity(無窮)" #: ../../builtins/functions.rst:828 msgid "__format__" -msgstr "" +msgstr "__format__" #: ../../builtins/functions.rst:828 ../../builtins/functions.rst:1947 msgid "string" -msgstr "" +msgstr "string(字串)" #: ../../builtins/functions.rst:828 msgid "format() (built-in function)" -msgstr "" +msgstr "format()(內建函式)" #: ../../builtins/functions.rst:1342 msgid "file object" -msgstr "" +msgstr "file object(檔案物件)" #: ../../builtins/functions.rst:1342 ../../builtins/functions.rst:1463 msgid "open() built-in function" -msgstr "" +msgstr "open() 內建函式" #: ../../builtins/functions.rst:1370 msgid "file" -msgstr "" +msgstr "file(檔案)" #: ../../builtins/functions.rst:1370 msgid "modes" -msgstr "" +msgstr "modes(模式)" #: ../../builtins/functions.rst:1463 msgid "universal newlines" -msgstr "" +msgstr "universal newlines" #: ../../builtins/functions.rst:1524 msgid "line-buffered I/O" -msgstr "" +msgstr "line-buffered I/O(行緩衝 I/O)" #: ../../builtins/functions.rst:1524 msgid "unbuffered I/O" -msgstr "" +msgstr "unbuffered I/O(非緩衝 I/O)" #: ../../builtins/functions.rst:1524 msgid "buffer size, I/O" -msgstr "" +msgstr "buffer size, I/O(緩衝區大小、I/O)" #: ../../builtins/functions.rst:1524 msgid "I/O control" -msgstr "" +msgstr "I/O control(I/O 控制)" #: ../../builtins/functions.rst:1524 msgid "buffering" -msgstr "" +msgstr "buffering(緩衝)" #: ../../builtins/functions.rst:1524 msgid "text mode" -msgstr "" +msgstr "text mode(文字模式)" #: ../../builtins/functions.rst:1524 ../../builtins/functions.rst:2245 msgid "module" -msgstr "" +msgstr "module(模組)" #: ../../builtins/functions.rst:1524 msgid "sys" -msgstr "" +msgstr "sys" #: ../../builtins/functions.rst:1947 msgid "str() (built-in function)" -msgstr "" +msgstr "str() (內建函式)" #: ../../builtins/functions.rst:2079 msgid "object" -msgstr "" +msgstr "object(物件)" #: ../../builtins/functions.rst:2245 msgid "statement" -msgstr "" +msgstr "statement(陳述式)" #: ../../builtins/functions.rst:2245 msgid "import" -msgstr "" +msgstr "import(引入)" #: ../../builtins/functions.rst:2245 msgid "builtins" -msgstr "" +msgstr "builtins(內建)" diff --git a/builtins/index.po b/builtins/index.po index 7465cd6eb0..97fd757a2c 100644 --- a/builtins/index.po +++ b/builtins/index.po @@ -19,11 +19,11 @@ msgstr "" #: ../../builtins/index.rst:5 msgid "Python built-ins reference" -msgstr "" +msgstr "Python 內建功能參考手冊" #: ../../builtins/index.rst:7 msgid "Python comes with a number of built-in functions and classes." -msgstr "" +msgstr "Python 內建了許多函式和類別。" #: ../../builtins/index.rst:9 msgid "" @@ -32,6 +32,9 @@ msgid "" "types, the Python language core defines the form of literals and places some " "constraints on their semantics, but does not fully define the semantics." msgstr "" +"內建類別包括了一般會被視為語言「核心」一部分的資料型別,例如數字和串列。對於" +"這些型別,Python 語言核心定義了字面值的形式,並對其語意加上一些限制,但並未完" +"整定義其語意。" #: ../../builtins/index.rst:14 msgid "" @@ -40,9 +43,14 @@ msgid "" "Some of these are defined by the core language, but many are not essential " "for the core semantics and are only described here." msgstr "" +"內建功能也包括函式和例外 --- 這些物件可供所有 Python 程式碼使用,而不需要 :" +"keyword:`import` 陳述式。其中一些是由核心語言所定義,但許多對核心語意而言並非" +"必要,僅在此處說明。" #: ../../builtins/index.rst:21 msgid "" "In addition to the built-ins, Python provides an extensive importable " "standard library, see :ref:`library-index`." msgstr "" +"除了內建功能之外,Python 還提供了廣泛的可引入標準函式庫,請參閱 :ref:" +"`library-index`\\ 。" diff --git a/builtins/stdtypes.po b/builtins/stdtypes.po index 851eefa5be..14a5910a3e 100644 --- a/builtins/stdtypes.po +++ b/builtins/stdtypes.po @@ -19,19 +19,19 @@ msgstr "" #: ../../builtins/stdtypes.rst:8 msgid "Built-in Types" -msgstr "" +msgstr "內建型別" #: ../../builtins/stdtypes.rst:10 msgid "" "The following sections describe the standard types that are built into the " "interpreter." -msgstr "" +msgstr "以下章節描述了直譯器中內建的標準型別。" #: ../../builtins/stdtypes.rst:15 msgid "" "The principal built-in types are numerics, sequences, mappings, classes, " "instances and exceptions." -msgstr "" +msgstr "主要內建型別為數字、序列、對映、class(類別)、實例和例外。" #: ../../builtins/stdtypes.rst:18 msgid "" @@ -39,6 +39,9 @@ msgid "" "rearrange their members in place, and don't return a specific item, never " "return the collection instance itself but ``None``." msgstr "" +"有些集合類別是 mutable(可變的)。那些用於原地 (in-place) 加入、移除或重新排" +"列其成員且不回傳特定項的 method(方法),也只會回傳 ``None`` 而非集合實例自" +"己。" #: ../../builtins/stdtypes.rst:22 msgid "" @@ -48,16 +51,21 @@ msgid "" "slightly different :func:`str` function). The latter function is implicitly " "used when an object is written by the :func:`print` function." msgstr "" +"某些操作已被多種物件型別支援;特別是實務上所有物件都已經可以做相等性比較、真" +"值檢測及被轉換為字串(使用 :func:`repr` 函式或稍有差異的 :func:`str` 函式)," +"後者為當物件傳入 :func:`print` 函式印出時在背後被呼叫的函式。" #: ../../builtins/stdtypes.rst:32 msgid "Truth Value Testing" -msgstr "" +msgstr "真值檢測" #: ../../builtins/stdtypes.rst:41 msgid "" "Any object can be tested for truth value, for use in an :keyword:`if` or :" "keyword:`while` condition or as operand of the Boolean operations below." msgstr "" +"任何物件都可以進行檢測以判斷是否為真值,以便在 :keyword:`if` 或 :keyword:" +"`while` 條件中使用,或是作為如下所述 boolean(布林)運算之運算元所用。" #: ../../builtins/stdtypes.rst:46 msgid "" @@ -68,22 +76,29 @@ msgid "" "and the object does not have a truth value (for example, :data:" "`NotImplemented`). Here are most of the built-in objects considered false:" msgstr "" +"預設情況下,一個物件會被視為真值,除非它的 class 定義了會回傳 ``False`` 的 :" +"meth:`~object.__bool__` method 或是定義了會回傳零的 :meth:`~object.__len__` " +"method。[1]_ 如果其中一個 method 在被呼叫時引發例外,該例外將會被傳播,且該物" +"件不具有真值(例如 :data:`NotImplemented`)。以下列出了大部分會被視為 false " +"的內建物件:" #: ../../builtins/stdtypes.rst:58 msgid "constants defined to be false: ``None`` and ``False``" -msgstr "" +msgstr "定義為 false 之常數:``None`` 與 ``False``" #: ../../builtins/stdtypes.rst:60 msgid "" "zero of any numeric type: ``0``, ``0.0``, ``0j``, ``Decimal(0)``, " "``Fraction(0, 1)``" msgstr "" +"任何數值型別的零:``0``、``0.0``、``0j``、``Decimal(0)``、``Fraction(0, 1)``" #: ../../builtins/stdtypes.rst:63 msgid "" "empty sequences and collections: ``''``, ``()``, ``[]``, ``{}``, ``set()``, " "``range(0)``" msgstr "" +"空的序列和集合:``''``、``()``、``[]``、``{}``、``set()``、``range(0)``" #: ../../builtins/stdtypes.rst:72 msgid "" @@ -92,71 +107,75 @@ msgid "" "otherwise stated. (Important exception: the Boolean operations ``or`` and " "``and`` always return one of their operands.)" msgstr "" +"除非另有特別說明,產生 boolean 結果的操作或內建函式都會回傳 ``0`` 或 " +"``False`` 作為假值、``1`` 或 ``True`` 作為真值。(重要例外: boolean 運算 " +"``or`` 和 ``and`` 回傳的是其中一個運算元。)" #: ../../builtins/stdtypes.rst:81 msgid "Boolean Operations --- :keyword:`!and`, :keyword:`!or`, :keyword:`!not`" msgstr "" +"Boolean(布林)運算 --- :keyword:`!and`, :keyword:`!or`, :keyword:`!not`" #: ../../builtins/stdtypes.rst:85 msgid "These are the Boolean operations, ordered by ascending priority:" -msgstr "" +msgstr "下方為 Boolean 運算,按優先順序排序:" #: ../../builtins/stdtypes.rst:88 ../../builtins/stdtypes.rst:146 #: ../../builtins/stdtypes.rst:292 ../../builtins/stdtypes.rst:382 #: ../../builtins/stdtypes.rst:432 ../../builtins/stdtypes.rst:1018 #: ../../builtins/stdtypes.rst:1242 msgid "Operation" -msgstr "" +msgstr "運算" #: ../../builtins/stdtypes.rst:88 ../../builtins/stdtypes.rst:292 #: ../../builtins/stdtypes.rst:382 ../../builtins/stdtypes.rst:432 #: ../../builtins/stdtypes.rst:1018 ../../builtins/stdtypes.rst:1242 msgid "Result" -msgstr "" +msgstr "結果" #: ../../builtins/stdtypes.rst:88 ../../builtins/stdtypes.rst:292 #: ../../builtins/stdtypes.rst:432 ../../builtins/stdtypes.rst:1018 #: ../../builtins/stdtypes.rst:1242 ../../builtins/stdtypes.rst:3201 #: ../../builtins/stdtypes.rst:4475 msgid "Notes" -msgstr "" +msgstr "註解" #: ../../builtins/stdtypes.rst:90 msgid "``x or y``" -msgstr "" +msgstr "``x or y``" #: ../../builtins/stdtypes.rst:90 msgid "if *x* is true, then *x*, else *y*" -msgstr "" +msgstr "假如 *x* 為真,則 *x*,否則 *y*" #: ../../builtins/stdtypes.rst:90 ../../builtins/stdtypes.rst:1020 #: ../../builtins/stdtypes.rst:1023 ../../builtins/stdtypes.rst:1257 #: ../../builtins/stdtypes.rst:3207 ../../builtins/stdtypes.rst:4481 msgid "\\(1)" -msgstr "" +msgstr "\\(1)" #: ../../builtins/stdtypes.rst:93 msgid "``x and y``" -msgstr "" +msgstr "``x and y``" #: ../../builtins/stdtypes.rst:93 msgid "if *x* is false, then *x*, else *y*" -msgstr "" +msgstr "假如 *x* 為假,則 *x*,否則 *y*" #: ../../builtins/stdtypes.rst:93 ../../builtins/stdtypes.rst:305 #: ../../builtins/stdtypes.rst:325 ../../builtins/stdtypes.rst:1268 #: ../../builtins/stdtypes.rst:3211 ../../builtins/stdtypes.rst:3213 #: ../../builtins/stdtypes.rst:4485 ../../builtins/stdtypes.rst:4487 msgid "\\(2)" -msgstr "" +msgstr "\\(2)" #: ../../builtins/stdtypes.rst:96 msgid "``not x``" -msgstr "" +msgstr "``not x``" #: ../../builtins/stdtypes.rst:96 msgid "if *x* is false, then ``True``, else ``False``" -msgstr "" +msgstr "假如 *x* 為假,則 ``True``,否則 ``False``" #: ../../builtins/stdtypes.rst:96 ../../builtins/stdtypes.rst:3215 #: ../../builtins/stdtypes.rst:3217 ../../builtins/stdtypes.rst:3219 @@ -164,36 +183,40 @@ msgstr "" #: ../../builtins/stdtypes.rst:4491 ../../builtins/stdtypes.rst:4493 #: ../../builtins/stdtypes.rst:4495 msgid "\\(3)" -msgstr "" +msgstr "\\(3)" #: ../../builtins/stdtypes.rst:105 ../../builtins/stdtypes.rst:336 #: ../../builtins/stdtypes.rst:450 ../../builtins/stdtypes.rst:1062 #: ../../builtins/stdtypes.rst:1272 ../../builtins/stdtypes.rst:3251 #: ../../builtins/stdtypes.rst:4525 msgid "Notes:" -msgstr "" +msgstr "註解:" #: ../../builtins/stdtypes.rst:108 msgid "" "This is a short-circuit operator, so it only evaluates the second argument " "if the first one is false." msgstr "" +"這是一個短路運算子,所以他只有在第一個引數為假時,才會對第二個引數求值。" #: ../../builtins/stdtypes.rst:112 msgid "" "This is a short-circuit operator, so it only evaluates the second argument " "if the first one is true." msgstr "" +"這是一個短路運算子,所以他只有在第一個引數為真時,才會對第二個引數求值。" #: ../../builtins/stdtypes.rst:116 msgid "" "``not`` has a lower priority than non-Boolean operators, so ``not a == b`` " "is interpreted as ``not (a == b)``, and ``a == not b`` is a syntax error." msgstr "" +"``not`` 比非 Boolean 運算子有較低的優先權,因此 ``not a == b`` 可直譯為 " +"``not (a == b)``,而 ``a == not b`` 會導致語法錯誤。" #: ../../builtins/stdtypes.rst:123 msgid "Comparisons" -msgstr "" +msgstr "比較運算" #: ../../builtins/stdtypes.rst:137 msgid "" @@ -203,80 +226,84 @@ msgid "" "< y and y <= z``, except that *y* is evaluated only once (but in both cases " "*z* is not evaluated at all when ``x < y`` is found to be false)." msgstr "" +"在 Python 裡共有 8 種比較運算。他們的優先順序都相同(皆優先於 Boolean 運" +"算)。比較運算可以任意的串連;例如,``x < y <= z`` 等同於 ``x < y and y <= " +"z``,差異只在於前者的 *y* 只有被求值一次(但在這兩個例子中,當 ``x < y`` 為假" +"時,*z* 皆不會被求值)。" #: ../../builtins/stdtypes.rst:143 msgid "This table summarizes the comparison operations:" -msgstr "" +msgstr "這個表格統整所有比較運算:" #: ../../builtins/stdtypes.rst:146 ../../builtins/stdtypes.rst:3178 #: ../../builtins/stdtypes.rst:3201 ../../builtins/stdtypes.rst:4452 #: ../../builtins/stdtypes.rst:4475 msgid "Meaning" -msgstr "" +msgstr "含義" #: ../../builtins/stdtypes.rst:148 msgid "``<``" -msgstr "" +msgstr "``<``" #: ../../builtins/stdtypes.rst:148 msgid "strictly less than" -msgstr "" +msgstr "小於" #: ../../builtins/stdtypes.rst:150 msgid "``<=``" -msgstr "" +msgstr "``<=``" #: ../../builtins/stdtypes.rst:150 msgid "less than or equal" -msgstr "" +msgstr "小於等於" #: ../../builtins/stdtypes.rst:152 msgid "``>``" -msgstr "" +msgstr "``>``" #: ../../builtins/stdtypes.rst:152 msgid "strictly greater than" -msgstr "" +msgstr "大於" #: ../../builtins/stdtypes.rst:154 msgid "``>=``" -msgstr "" +msgstr "``>=``" #: ../../builtins/stdtypes.rst:154 msgid "greater than or equal" -msgstr "" +msgstr "大於等於" #: ../../builtins/stdtypes.rst:156 msgid "``==``" -msgstr "" +msgstr "``==``" #: ../../builtins/stdtypes.rst:156 msgid "equal" -msgstr "" +msgstr "等於" #: ../../builtins/stdtypes.rst:158 msgid "``!=``" -msgstr "" +msgstr "``!=``" #: ../../builtins/stdtypes.rst:158 msgid "not equal" -msgstr "" +msgstr "不等於" #: ../../builtins/stdtypes.rst:160 msgid "``is``" -msgstr "" +msgstr "``is``" #: ../../builtins/stdtypes.rst:160 msgid "object identity" -msgstr "" +msgstr "物件識別性" #: ../../builtins/stdtypes.rst:162 msgid "``is not``" -msgstr "" +msgstr "``is not``" #: ../../builtins/stdtypes.rst:162 msgid "negated object identity" -msgstr "" +msgstr "否定的物件識別性" #: ../../builtins/stdtypes.rst:169 msgid "" @@ -287,12 +314,18 @@ msgid "" "raise a :exc:`TypeError` exception when one of the arguments is a complex " "number." msgstr "" +"除非有另外聲明,不同型別的物件不能進行相等比較。運算子 ``==`` 總有定義,但在" +"某些物件型別(例如,class 物件)時,運算子會等同於 :keyword:`is`。其他運算子 " +"``<``、``<=``、``>`` 及 ``>=`` 皆僅在有意義的部分有所定義;例如,當其中一個引" +"數為複數時,將引發一個 :exc:`TypeError` 的例外。" #: ../../builtins/stdtypes.rst:183 msgid "" "Non-identical instances of a class normally compare as non-equal unless the " "class defines the :meth:`~object.__eq__` method." msgstr "" +"一個 class 的非相同實例通常會比較為不相等,除非 class 有定義 :meth:`~object." +"__eq__` method。" #: ../../builtins/stdtypes.rst:186 msgid "" @@ -303,6 +336,11 @@ msgid "" "meth:`~object.__eq__` are sufficient, if you want the conventional meanings " "of the comparison operators)." msgstr "" +"一個 class 的實例不可以與其他相同 class 的實例或其他物件型別進行排序,除非 " +"class 定義足夠的 method ,包含 :meth:`~object.__lt__`、:meth:`~object." +"__le__`、:meth:`~object.__gt__` 及 :meth:`~object.__ge__`\\ (一般來說,使" +"用 :meth:`~object.__lt__` 及 :meth:`~object.__eq__` 就可以滿足常規意義上的比" +"較運算子)。" #: ../../builtins/stdtypes.rst:193 msgid "" @@ -310,6 +348,8 @@ msgid "" "customized; also they can be applied to any two objects and never raise an " "exception." msgstr "" +"無法自訂 :keyword:`is` 與 :keyword:`is not` 運算子的行為;這兩個運算子也可以" +"運用在任意兩個物件且不會引發例外。" #: ../../builtins/stdtypes.rst:201 msgid "" @@ -317,10 +357,13 @@ msgid "" "keyword:`not in`, are supported by types that are :term:`iterable` or " "implement the :meth:`~object.__contains__` method." msgstr "" +"此外,擁有相同的語法優先序的 :keyword:`in` 及 :keyword:`not in` 兩種運算皆被" +"\\ :term:`可疊代物件 `\\ 或者有實作 :meth:`~object.__contains__` " +"method 的型別所支援。" #: ../../builtins/stdtypes.rst:208 msgid "Numeric Types --- :class:`int`, :class:`float`, :class:`complex`" -msgstr "" +msgstr "數值型別 --- :class:`int`、:class:`float`、:class:`complex`" #: ../../builtins/stdtypes.rst:218 msgid "" @@ -336,6 +379,13 @@ msgid "" "numeric types :mod:`fractions.Fraction`, for rationals, and :mod:`decimal." "Decimal`, for floating-point numbers with user-definable precision.)" msgstr "" +"數值型別共有三種::dfn:`整數`、:dfn:`浮點數` 及 :dfn:`複數`。此外,Boolean 為" +"整數中的一個子型別。整數有無限的精度。浮點數通常使用 C 裡面的 :c:expr:" +"`double` 實作。關於在你程式所運作的機器上之浮點數的精度及內部表示法可以在 :" +"data:`sys.float_info` 進行查找。複數包含實數及虛數的部分,這兩部分各自是一個" +"浮點數。若要從一個複數 *z* 提取這兩部分,需使用 ``z.real`` 及 ``z.imag``。" +"(標準函式庫包含額外的數值型別,像是 :mod:`fractions.Fraction` 表示有理數," +"而 :mod:`decimal.Decimal` 表示可由使用者制定精度的浮點數。)" #: ../../builtins/stdtypes.rst:240 msgid "" @@ -347,12 +397,18 @@ msgid "" "with a zero real part) which you can add to an integer or float to get a " "complex number with real and imaginary parts." msgstr "" +"數字是由字面數值或內建公式及運算子的結果所產生的。未經修飾的字面數值(含十六" +"進位、八進位及二進位數值)會 yield 整數。包含小數點或指數符號的字面數值會 " +"yield 浮點數。在數值後面加上 ``'j'`` 或是 ``'J'`` 會 yield 一個虛數(意即一個" +"實數為 0 的複數)。你也可以將整數與浮點數相加以得到一個有實部與虛部的複數。" #: ../../builtins/stdtypes.rst:248 msgid "" "The constructors :func:`int`, :func:`float`, and :func:`complex` can be used " "to produce numbers of a specific type." msgstr "" +"建構函式: :func:`int`、:func:`float` 及 :func:`complex` 可以用來產生特定型別" +"的數字。" #: ../../builtins/stdtypes.rst:270 msgid "" @@ -360,6 +416,8 @@ msgid "" "has operands of different built-in numeric types, the operand with the " "\"narrower\" type is widened to that of the other:" msgstr "" +"Python 完全支援混和運算:當一個二元運算子的運算元有不同內建數值型別時,「較" +"窄」型別的運算元會被拓寬到另一個型別的運算元:" #: ../../builtins/stdtypes.rst:274 msgid "If both arguments are complex numbers, no conversion is performed;" @@ -386,196 +444,200 @@ msgid "" "x + complex(u, v) = complex(x + u, v)\n" "x * complex(u, v) = complex(x * u, x * v)" msgstr "" +"x + complex(u, v) = complex(x + u, v)\n" +"x * complex(u, v) = complex(x * u, x * v)" #: ../../builtins/stdtypes.rst:285 msgid "" "A comparison between numbers of different types behaves as though the exact " "values of those numbers were being compared. [2]_" -msgstr "" +msgstr "不同型別的數值之間進行比較時,其行為就像是在比較這些數值的實際值 [2]_" #: ../../builtins/stdtypes.rst:288 msgid "" "All numeric types (except complex) support the following operations (for " "priorities of the operations, see :ref:`operator-summary`):" msgstr "" +"所有數值型別(除複數外)皆支援以下的運算(有關運算的先後順序,詳見 :ref:" +"`operator-summary`):" #: ../../builtins/stdtypes.rst:292 msgid "Full documentation" -msgstr "" +msgstr "完整文件" #: ../../builtins/stdtypes.rst:294 msgid "``x + y``" -msgstr "" +msgstr "``x + y``" #: ../../builtins/stdtypes.rst:294 msgid "sum of *x* and *y*" -msgstr "" +msgstr "*x* 及 *y* 的加總" #: ../../builtins/stdtypes.rst:296 msgid "``x - y``" -msgstr "" +msgstr "``x - y``" #: ../../builtins/stdtypes.rst:296 msgid "difference of *x* and *y*" -msgstr "" +msgstr "*x* 及 *y* 的相減" #: ../../builtins/stdtypes.rst:298 msgid "``x * y``" -msgstr "" +msgstr "``x * y``" #: ../../builtins/stdtypes.rst:298 msgid "product of *x* and *y*" -msgstr "" +msgstr "*x* 及 *y* 的相乘" #: ../../builtins/stdtypes.rst:300 msgid "``x / y``" -msgstr "" +msgstr "``x / y``" #: ../../builtins/stdtypes.rst:300 msgid "quotient of *x* and *y*" -msgstr "" +msgstr "*x* 及 *y* 相除之商" #: ../../builtins/stdtypes.rst:302 msgid "``x // y``" -msgstr "" +msgstr "``x // y``" #: ../../builtins/stdtypes.rst:302 msgid "floored quotient of *x* and *y*" -msgstr "" +msgstr "*x* 及 *y* 的整數除法" #: ../../builtins/stdtypes.rst:302 msgid "\\(1)\\(2)" -msgstr "" +msgstr "\\(1)\\(2)" #: ../../builtins/stdtypes.rst:305 msgid "``x % y``" -msgstr "" +msgstr "``x % y``" #: ../../builtins/stdtypes.rst:305 msgid "remainder of ``x / y``" -msgstr "" +msgstr "``x / y`` 的餘數" #: ../../builtins/stdtypes.rst:307 msgid "``-x``" -msgstr "" +msgstr "``-x``" #: ../../builtins/stdtypes.rst:307 msgid "*x* negated" -msgstr "" +msgstr "*x* 的負數" #: ../../builtins/stdtypes.rst:309 msgid "``+x``" -msgstr "" +msgstr "``+x``" #: ../../builtins/stdtypes.rst:309 msgid "*x* unchanged" -msgstr "" +msgstr "*x* 不變" #: ../../builtins/stdtypes.rst:311 msgid "``abs(x)``" -msgstr "" +msgstr "``abs(x)``" #: ../../builtins/stdtypes.rst:311 msgid "absolute value or magnitude of *x*" -msgstr "" +msgstr "*x* 的絕對值或量 (magnitude)" #: ../../builtins/stdtypes.rst:311 msgid ":func:`abs`" -msgstr "" +msgstr ":func:`abs`" #: ../../builtins/stdtypes.rst:314 msgid "``int(x)``" -msgstr "" +msgstr "``int(x)``" #: ../../builtins/stdtypes.rst:314 msgid "*x* converted to integer" -msgstr "" +msgstr "將 *x* 轉為整數" #: ../../builtins/stdtypes.rst:314 msgid "\\(3)\\(6)" -msgstr "" +msgstr "\\(3)\\(6)" #: ../../builtins/stdtypes.rst:314 msgid ":func:`int`" -msgstr "" +msgstr ":func:`int`" #: ../../builtins/stdtypes.rst:316 msgid "``float(x)``" -msgstr "" +msgstr "``float(x)``" #: ../../builtins/stdtypes.rst:316 msgid "*x* converted to floating point" -msgstr "" +msgstr "將 *x* 轉為浮點數" #: ../../builtins/stdtypes.rst:316 msgid "\\(4)\\(6)" -msgstr "" +msgstr "\\(4)\\(6)" #: ../../builtins/stdtypes.rst:316 msgid ":func:`float`" -msgstr "" +msgstr ":func:`float`" #: ../../builtins/stdtypes.rst:318 msgid "``complex(re, im)``" -msgstr "" +msgstr "``complex(re, im)``" #: ../../builtins/stdtypes.rst:318 msgid "" "a complex number with real part *re*, imaginary part *im*. *im* defaults to " "zero." -msgstr "" +msgstr "一個複數,其實部為 *re*,虛部為 *im*。*im* 預設為零。" #: ../../builtins/stdtypes.rst:318 ../../builtins/stdtypes.rst:3209 #: ../../builtins/stdtypes.rst:4512 msgid "\\(6)" -msgstr "" +msgstr "\\(6)" #: ../../builtins/stdtypes.rst:318 msgid ":func:`complex`" -msgstr "" +msgstr ":func:`complex`" #: ../../builtins/stdtypes.rst:322 msgid "``c.conjugate()``" -msgstr "" +msgstr "``c.conjugate()``" #: ../../builtins/stdtypes.rst:322 msgid "conjugate of the complex number *c*" -msgstr "" +msgstr "為複數 *c* 的共軛複數" #: ../../builtins/stdtypes.rst:325 msgid "``divmod(x, y)``" -msgstr "" +msgstr "``divmod(x, y)``" #: ../../builtins/stdtypes.rst:325 msgid "the pair ``(x // y, x % y)``" -msgstr "" +msgstr "一對 ``(x // y, x % y)``" #: ../../builtins/stdtypes.rst:325 msgid ":func:`divmod`" -msgstr "" +msgstr ":func:`divmod`" #: ../../builtins/stdtypes.rst:327 msgid "``pow(x, y)``" -msgstr "" +msgstr "``pow(x, y)``" #: ../../builtins/stdtypes.rst:327 ../../builtins/stdtypes.rst:329 msgid "*x* to the power *y*" -msgstr "" +msgstr "*x* 的 *y* 次方" #: ../../builtins/stdtypes.rst:327 ../../builtins/stdtypes.rst:329 #: ../../builtins/stdtypes.rst:3234 ../../builtins/stdtypes.rst:3237 #: ../../builtins/stdtypes.rst:3240 ../../builtins/stdtypes.rst:4508 #: ../../builtins/stdtypes.rst:4515 msgid "\\(5)" -msgstr "" +msgstr "\\(5)" #: ../../builtins/stdtypes.rst:327 msgid ":func:`pow`" -msgstr "" +msgstr ":func:`pow`" #: ../../builtins/stdtypes.rst:329 msgid "``x ** y``" -msgstr "" +msgstr "``x ** y``" #: ../../builtins/stdtypes.rst:339 msgid "" @@ -586,12 +648,17 @@ msgid "" "always rounded towards minus infinity: ``1//2`` is ``0``, ``(-1)//2`` is " "``-1``, ``1//(-2)`` is ``-1``, and ``(-1)//(-2)`` is ``0``." msgstr "" +"也被稱為整數除法。對於型別為 :class:`int` 的運算元來說,結果之型別會是 :" +"class:`int`。對於型別為 :class:`float` 的運算元來說,結果之型別會是 :class:" +"`float`。一般來說,結果會是一個整數,但其型別不一定會是 :class:`int`。結果總" +"是會往負無窮大的方向取整數值: ``1//2`` 為 ``0``、``(-1)//2`` 為 ``-1``、" +"``1//(-2)`` 為 ``-1`` 及 ``(-1)//(-2)`` 為 ``0``。" #: ../../builtins/stdtypes.rst:347 msgid "" "Not for complex numbers. Instead convert to floats using :func:`abs` if " "appropriate." -msgstr "" +msgstr "不可用於複數。在適當情形下,可使用 :func:`abs` 轉換為浮點數。" #: ../../builtins/stdtypes.rst:358 msgid "" @@ -599,24 +666,31 @@ msgid "" "fractional part. See functions :func:`math.floor` and :func:`math.ceil` for " "alternative conversions." msgstr "" +"從 :class:`float` 轉換為 :class:`int` 會導致截斷並排除小數部分。詳見 :func:" +"`math.floor` 及 :func:`math.ceil` 以了解更多轉換方式。" #: ../../builtins/stdtypes.rst:363 msgid "" "float also accepts the strings \"nan\" and \"inf\" with an optional prefix " "\"+\" or \"-\" for Not a Number (NaN) and positive or negative infinity." msgstr "" +"浮點數也接受帶有可選的前綴 \"+\" 及 \"-\" 的 \"nan\" 及 \"inf\" 字串,其分別" +"代表非數字(NaN)及正負無窮。" #: ../../builtins/stdtypes.rst:367 msgid "" "Python defines ``pow(0, 0)`` and ``0 ** 0`` to be ``1``, as is common for " "programming languages." msgstr "" +"Python 將 ``pow(0, 0)`` 及 ``0 ** 0`` 定義為 ``1`` 這是程式語言的普遍做法。" #: ../../builtins/stdtypes.rst:371 msgid "" "The numeric literals accepted include the digits ``0`` to ``9`` or any " "Unicode equivalent (code points with the ``Nd`` property)." msgstr "" +"字面數值接受包含數字 ``0`` 到 ``9`` 或任何等效的 Unicode 字元(具有 ``Nd`` 屬" +"性的 code points(編碼位置))。" #: ../../builtins/stdtypes.rst:374 msgid "" @@ -624,56 +698,60 @@ msgid "" "DerivedNumericType.txt>`_ for a complete list of code points with the ``Nd`` " "property." msgstr "" +"請參閱 `Unicode 標準 `_\\ 以了解具有 ``Nd`` 屬性的 code points 完整列表。" #: ../../builtins/stdtypes.rst:378 msgid "" "All :class:`numbers.Real` types (:class:`int` and :class:`float`) also " "include the following operations:" msgstr "" +"所有 :class:`numbers.Real` 型別(:class:`int` 及 :class:`float`)也適用下列運" +"算:" #: ../../builtins/stdtypes.rst:384 msgid ":func:`math.trunc(\\ x) `" -msgstr "" +msgstr ":func:`math.trunc(\\ x) `" #: ../../builtins/stdtypes.rst:384 msgid "*x* truncated to :class:`~numbers.Integral`" -msgstr "" +msgstr "*x* 截斷為 :class:`~numbers.Integral`" #: ../../builtins/stdtypes.rst:387 msgid ":func:`round(x[, n]) `" -msgstr "" +msgstr ":func:`round(x[, n]) `" #: ../../builtins/stdtypes.rst:387 msgid "" "*x* rounded to *n* digits, rounding half to even. If *n* is omitted, it " "defaults to 0." -msgstr "" +msgstr "*x* 進位至小數點後第 *n* 位,使用偶數捨入法。若省略 *n* ,則預設為 0。" #: ../../builtins/stdtypes.rst:391 msgid ":func:`math.floor(\\ x) `" -msgstr "" +msgstr ":func:`math.floor(\\ x) `" #: ../../builtins/stdtypes.rst:391 msgid "the greatest :class:`~numbers.Integral` <= *x*" -msgstr "" +msgstr "小於等於 *x* 的最大 :class:`~numbers.Integral`" #: ../../builtins/stdtypes.rst:394 msgid ":func:`math.ceil(x) `" -msgstr "" +msgstr ":func:`math.ceil(x) `" #: ../../builtins/stdtypes.rst:394 msgid "the least :class:`~numbers.Integral` >= *x*" -msgstr "" +msgstr "大於等於 *x* 的最小 :class:`~numbers.Integral`" #: ../../builtins/stdtypes.rst:398 msgid "" "For additional numeric operations see the :mod:`math` and :mod:`cmath` " "modules." -msgstr "" +msgstr "關於其他數值運算請詳見 :mod:`math` 及 :mod:`cmath` modules(模組)。" #: ../../builtins/stdtypes.rst:407 msgid "Bitwise Operations on Integer Types" -msgstr "" +msgstr "整數型別的位元運算" #: ../../builtins/stdtypes.rst:421 msgid "" @@ -681,6 +759,8 @@ msgid "" "operations is calculated as though carried out in two's complement with an " "infinite number of sign bits." msgstr "" +"位元運算只對整數有意義。位元運算的計算結果就如同對二的補數執行無窮多個符號位" +"元。" #: ../../builtins/stdtypes.rst:425 msgid "" @@ -689,88 +769,90 @@ msgid "" "``~`` has the same priority as the other unary numeric operations (``+`` and " "``-``)." msgstr "" +"二元位元運算的優先順序皆低於數字運算,但高於比較運算;一元運算 ``~`` 與其他一" +"元數值運算有一致的優先順序(``+`` 及 ``-``)。" #: ../../builtins/stdtypes.rst:429 msgid "This table lists the bitwise operations sorted in ascending priority:" -msgstr "" +msgstr "這個表格列出所有位元運算並以優先順序由先至後排序。" #: ../../builtins/stdtypes.rst:434 msgid "``x | y``" -msgstr "" +msgstr "``x | y``" #: ../../builtins/stdtypes.rst:434 msgid "bitwise :dfn:`or` of *x* and *y*" -msgstr "" +msgstr "*x* 及 *y* 的位元 :dfn:`或`" #: ../../builtins/stdtypes.rst:434 ../../builtins/stdtypes.rst:437 #: ../../builtins/stdtypes.rst:440 ../../builtins/stdtypes.rst:3223 #: ../../builtins/stdtypes.rst:3227 ../../builtins/stdtypes.rst:4497 #: ../../builtins/stdtypes.rst:4501 msgid "\\(4)" -msgstr "" +msgstr "\\(4)" #: ../../builtins/stdtypes.rst:437 msgid "``x ^ y``" -msgstr "" +msgstr "``x ^ y``" #: ../../builtins/stdtypes.rst:437 msgid "bitwise :dfn:`exclusive or` of *x* and *y*" -msgstr "" +msgstr "*x* 及 *y* 的位元 :dfn:`邏輯互斥或`" #: ../../builtins/stdtypes.rst:440 msgid "``x & y``" -msgstr "" +msgstr "``x & y``" #: ../../builtins/stdtypes.rst:440 msgid "bitwise :dfn:`and` of *x* and *y*" -msgstr "" +msgstr "*x* 及 *y* 的位元 :dfn:`與`" #: ../../builtins/stdtypes.rst:443 msgid "``x << n``" -msgstr "" +msgstr "``x << n``" #: ../../builtins/stdtypes.rst:443 msgid "*x* shifted left by *n* bits" -msgstr "" +msgstr "*x* 往左移動 *n* 個位元" #: ../../builtins/stdtypes.rst:443 msgid "(1)(2)" -msgstr "" +msgstr "(1)(2)" #: ../../builtins/stdtypes.rst:445 msgid "``x >> n``" -msgstr "" +msgstr "``x >> n``" #: ../../builtins/stdtypes.rst:445 msgid "*x* shifted right by *n* bits" -msgstr "" +msgstr "*x* 往右移動 *n* 個位元" #: ../../builtins/stdtypes.rst:445 msgid "(1)(3)" -msgstr "" +msgstr "(1)(3)" #: ../../builtins/stdtypes.rst:447 msgid "``~x``" -msgstr "" +msgstr "``~x``" #: ../../builtins/stdtypes.rst:447 msgid "the bits of *x* inverted" -msgstr "" +msgstr "反轉 *x* 的位元" #: ../../builtins/stdtypes.rst:453 msgid "" "Negative shift counts are illegal and cause a :exc:`ValueError` to be raised." -msgstr "" +msgstr "負數位移是不被允許並會引發 :exc:`ValueError` 的錯誤。" #: ../../builtins/stdtypes.rst:456 msgid "" "A left shift by *n* bits is equivalent to multiplication by ``pow(2, n)``." -msgstr "" +msgstr "向左移動 *n* 個位元等同於乘以 ``pow(2, n)``。" #: ../../builtins/stdtypes.rst:459 msgid "" "A right shift by *n* bits is equivalent to floor division by ``pow(2, n)``." -msgstr "" +msgstr "向右移動 *n* 個位元等同於向下除法除以 ``pow(2, n)``。" #: ../../builtins/stdtypes.rst:462 msgid "" @@ -779,22 +861,27 @@ msgid "" "bit_length(), y.bit_length())`` or more) is sufficient to get the same " "result as if there were an infinite number of sign bits." msgstr "" +"在有限的二的補數表示法中執行這些計算(一個有效位元寬度為 ``1 + max(x." +"bit_length(), y.bit_length())`` 或以上)並至少有一個額外的符號擴展位元,便足" +"以得到與無窮多個符號位元相同的結果。" #: ../../builtins/stdtypes.rst:469 msgid "Additional Methods on Integer Types" -msgstr "" +msgstr "整數型別的附加方法" #: ../../builtins/stdtypes.rst:471 msgid "" "The int type implements the :class:`numbers.Integral` :term:`abstract base " "class`. In addition, it provides a few more methods:" msgstr "" +"整數型別實作了 :class:`numbers.Integral` :term:`抽象基底類別 `。此外,它提供了一些方法:" #: ../../builtins/stdtypes.rst:476 msgid "" "Return the number of bits necessary to represent an integer in binary, " "excluding the sign and leading zeros::" -msgstr "" +msgstr "回傳以二進位表示一個整數所需要的位元數,不包括符號及首位的零: ::" #: ../../builtins/stdtypes.rst:479 msgid "" @@ -804,6 +891,11 @@ msgid "" ">>> n.bit_length()\n" "6" msgstr "" +">>> n = -37\n" +">>> bin(n)\n" +"'-0b100101'\n" +">>> n.bit_length()\n" +"6" #: ../../builtins/stdtypes.rst:485 msgid "" @@ -813,11 +905,15 @@ msgid "" "logarithm, then ``k = 1 + int(log(abs(x), 2))``. If ``x`` is zero, then ``x." "bit_length()`` returns ``0``." msgstr "" +"更準確來說,若 ``x`` 非為零,則 ``x.bit_length()`` 會得出滿足 ``2**(k-1) <= " +"abs(x) < 2**k`` 的單一正整數 ``k``。同樣地,當 ``abs(x)`` 足夠小到能正確地取" +"得捨入的對數,則 ``k = 1 + int(log(abs(x), 2))``。若 ``x`` 為零,則 ``x." +"bit_length()`` 會回傳 ``0``。" #: ../../builtins/stdtypes.rst:491 ../../builtins/stdtypes.rst:514 #: ../../builtins/stdtypes.rst:559 ../../builtins/stdtypes.rst:603 msgid "Equivalent to::" -msgstr "" +msgstr "等同於: ::" #: ../../builtins/stdtypes.rst:493 msgid "" @@ -826,12 +922,16 @@ msgid "" " s = s.lstrip('-0b') # remove leading zeros and minus sign\n" " return len(s) # len('100101') --> 6" msgstr "" +"def bit_length(self):\n" +" s = bin(self) # 二進位表示: bin(-37) --> '-0b100101'\n" +" s = s.lstrip('-0b') # 去除開頭的零和負號\n" +" return len(s) # len('100101') --> 6" #: ../../builtins/stdtypes.rst:502 msgid "" "Return the number of ones in the binary representation of the absolute value " "of the integer. This is also known as the population count. Example::" -msgstr "" +msgstr "回傳在絕對值表示的二進位中 1 的個數。這也被稱作母體計數。舉例來說: ::" #: ../../builtins/stdtypes.rst:506 msgid "" @@ -843,16 +943,25 @@ msgid "" ">>> (-n).bit_count()\n" "3" msgstr "" +">>> n = 19\n" +">>> bin(n)\n" +"'0b10011'\n" +">>> n.bit_count()\n" +"3\n" +">>> (-n).bit_count()\n" +"3" #: ../../builtins/stdtypes.rst:516 msgid "" "def bit_count(self):\n" " return bin(self).count(\"1\")" msgstr "" +"def bit_count(self):\n" +" return bin(self).count(\"1\")" #: ../../builtins/stdtypes.rst:523 msgid "Return an array of bytes representing an integer." -msgstr "" +msgstr "回傳表示一個整數的一列位元組。" #: ../../builtins/stdtypes.rst:535 msgid "" @@ -860,6 +969,8 @@ msgid "" "`OverflowError` is raised if the integer is not representable with the given " "number of bytes." msgstr "" +"此整數會使用 *length* 位元組表示,並且預設為 1。如果該整數無法用給定的位元組" +"數來表示,則會引發 :exc:`OverflowError`。" #: ../../builtins/stdtypes.rst:539 msgid "" @@ -868,6 +979,9 @@ msgid "" "most significant byte is at the beginning of the byte array. If *byteorder* " "is ``\"little\"``, the most significant byte is at the end of the byte array." msgstr "" +"*byteorder* 引數決定了用來表示整數的位元組順序並且預設為 ``\"big\"``。如果 " +"byteorder 是 ``\"big\"``,最重要的位元組位於位元組陣列的開頭。如果 byteorder " +"是 ``\"little\"``,最重要的位元組位於位元組陣列的結尾。" #: ../../builtins/stdtypes.rst:545 msgid "" @@ -876,24 +990,31 @@ msgid "" "given, an :exc:`OverflowError` is raised. The default value for *signed* is " "``False``." msgstr "" +"*signed* 引數決定是否使用二的補數來表示整數。如果 *signed* 是 ``False`` 並且" +"給定了一個負整數,則會引發 :exc:`OverflowError`。*signed* 的預設值是 " +"``False``。" #: ../../builtins/stdtypes.rst:550 msgid "" "The default values can be used to conveniently turn an integer into a single " "byte object::" -msgstr "" +msgstr "預設值可以方便地將一個整數轉換為單一位元組物件: ::" #: ../../builtins/stdtypes.rst:553 msgid "" ">>> (65).to_bytes()\n" "b'A'" msgstr "" +">>> (65).to_bytes()\n" +"b'A'" #: ../../builtins/stdtypes.rst:556 msgid "" "However, when using the default arguments, don't try to convert a value " "greater than 255 or you'll get an :exc:`OverflowError`." msgstr "" +"然而,使用預設引數時,不要嘗試轉換大於 255 的值,否則你將會得到一個 :exc:" +"`OverflowError`。" #: ../../builtins/stdtypes.rst:561 msgid "" @@ -907,20 +1028,31 @@ msgid "" "\n" " return bytes((n >> i*8) & 0xff for i in order)" msgstr "" +"def to_bytes(n, length=1, byteorder='big', signed=False):\n" +" if byteorder == 'little':\n" +" order = range(length)\n" +" elif byteorder == 'big':\n" +" order = reversed(range(length))\n" +" else:\n" +" raise ValueError(\"byteorder must be either 'little' or 'big'\")\n" +"\n" +" return bytes((n >> i*8) & 0xff for i in order)" #: ../../builtins/stdtypes.rst:572 msgid "Added default argument values for ``length`` and ``byteorder``." -msgstr "" +msgstr "為 ``length`` 和 ``byteorder`` 添加了預設引數值。" #: ../../builtins/stdtypes.rst:577 msgid "Return the integer represented by the given array of bytes." -msgstr "" +msgstr "回傳由給定的位元組陣列表示的整數。" #: ../../builtins/stdtypes.rst:590 msgid "" "The argument *bytes* must either be a :term:`bytes-like object` or an " "iterable producing bytes." msgstr "" +"引數 *bytes* 必須是一個\\ :term:`類位元組物件 `\\ 或是一個" +"產生位元組的可疊代物件。" #: ../../builtins/stdtypes.rst:593 msgid "" @@ -931,12 +1063,16 @@ msgid "" "array. To request the native byte order of the host system, use :data:`sys." "byteorder` as the byte order value." msgstr "" +"*byteorder* 引數決定了用來表示整數的位元組順序並且預設為 ``\"big\"``。如果 " +"*byteorder* 是 ``\"big\"``,最重要的位元組位於位元組陣列的開頭。如果 " +"*byteorder* 是 ``\"little\"``,最重要的位元組位於位元組陣列的結尾。若要請求主" +"機系統的本機位元組順序,請使用 :data:`sys.byteorder` 作為位元組順序值。" #: ../../builtins/stdtypes.rst:600 msgid "" "The *signed* argument indicates whether two's complement is used to " "represent the integer." -msgstr "" +msgstr "*signed* 引數指示是否使用二的補數來表示整數。" #: ../../builtins/stdtypes.rst:605 msgid "" @@ -954,10 +1090,23 @@ msgid "" "\n" " return n" msgstr "" +"def from_bytes(bytes, byteorder='big', signed=False):\n" +" if byteorder == 'little':\n" +" little_ordered = list(bytes)\n" +" elif byteorder == 'big':\n" +" little_ordered = list(reversed(bytes))\n" +" else:\n" +" raise ValueError(\"byteorder must be either 'little' or 'big'\")\n" +"\n" +" n = sum(b << i*8 for i, b in enumerate(little_ordered))\n" +" if signed and little_ordered and (little_ordered[-1] & 0x80):\n" +" n -= 1 << 8*len(little_ordered)\n" +"\n" +" return n" #: ../../builtins/stdtypes.rst:620 msgid "Added default argument value for ``byteorder``." -msgstr "" +msgstr "為 ``byteorder`` 添加了預設引數值。" #: ../../builtins/stdtypes.rst:625 msgid "" @@ -965,27 +1114,31 @@ msgid "" "has a positive denominator. The integer ratio of integers (whole numbers) " "is always the integer as the numerator and ``1`` as the denominator." msgstr "" +"回傳一對整數,其比率等於原始整數並且有一個正分母。整數(整個數值)的整數比率" +"總是整數作為分子,並且 ``1`` 作為分母。" #: ../../builtins/stdtypes.rst:634 msgid "" "Returns ``True``. Exists for duck type compatibility with :meth:`float." "is_integer`." -msgstr "" +msgstr "回傳 ``True``。為了與 :meth:`float.is_integer` 的鴨子型別相容而存在。" #: ../../builtins/stdtypes.rst:639 msgid "Additional Methods on Float" -msgstr "" +msgstr "浮點數的附加方法" #: ../../builtins/stdtypes.rst:641 msgid "" "The float type implements the :class:`numbers.Real` :term:`abstract base " "class`. float also has the following additional methods." msgstr "" +"浮點數型別實作了 :class:`numbers.Real` :term:`抽象基底類別 `。浮點數也有下列附加方法。" #: ../../builtins/stdtypes.rst:646 msgid "" "Class method to return a floating-point number constructed from a number *x*." -msgstr "" +msgstr "Class method 會基於數字 *x* 建構並回傳一個浮點數。" #: ../../builtins/stdtypes.rst:648 msgid "" @@ -994,6 +1147,8 @@ msgid "" "returned. If the argument is outside the range of a Python float, an :exc:" "`OverflowError` will be raised." msgstr "" +"如果參數是整數或浮點數,將回傳具有相同值的浮點數(在 Python 浮點數精度範圍" +"內)。如果參數超出 Python 浮點數的範圍,將引發 :exc:`OverflowError`。" #: ../../builtins/stdtypes.rst:653 msgid "" @@ -1001,6 +1156,9 @@ msgid "" "__float__()``. If :meth:`~object.__float__` is not defined then it falls " "back to :meth:`~object.__index__`." msgstr "" +"對於任意 Python 物件 ``x``,``float.from_number(x)`` 會委派給 ``x." +"__float__()``。若 :meth:`~object.__float__` 未定義,則會退回 :meth:`~object." +"__index__`。" #: ../../builtins/stdtypes.rst:663 msgid "" @@ -1008,12 +1166,16 @@ msgid "" "float. The ratio is in lowest terms and has a positive denominator. Raises :" "exc:`OverflowError` on infinities and a :exc:`ValueError` on NaNs." msgstr "" +"回傳一對整數,其比率完全等於原始浮點數。比率是在最低條件下並且有一個正分母。" +"在無窮大時引發 :exc:`OverflowError`,在 NaN 時引發 :exc:`ValueError`。" #: ../../builtins/stdtypes.rst:670 msgid "" "Return ``True`` if the float instance is finite with integral value, and " "``False`` otherwise::" msgstr "" +"如果浮點數實例是有限的並且具有整數值,則回傳 ``True``,否則回傳 " +"``False``: ::" #: ../../builtins/stdtypes.rst:673 msgid "" @@ -1022,6 +1184,10 @@ msgid "" ">>> (3.2).is_integer()\n" "False" msgstr "" +">>> (-2.0).is_integer()\n" +"True\n" +">>> (3.2).is_integer()\n" +"False" #: ../../builtins/stdtypes.rst:678 msgid "" @@ -1032,6 +1198,9 @@ msgid "" "of floating-point numbers. This can be useful when debugging, and in " "numerical work." msgstr "" +"兩個 methods 皆支援十六進位字串之間的轉換。由於 Python 的浮點數內部以二進位數" +"值儲存,將浮點數轉換為或從 *十進位* 字串通常涉及一個小的四捨五入誤差。相反" +"地,十六進位字串允許精確表示和指定浮點數。這在除錯和數值工作中可能會有用。" #: ../../builtins/stdtypes.rst:689 msgid "" @@ -1039,26 +1208,32 @@ msgid "" "For finite floating-point numbers, this representation will always include a " "leading ``0x`` and a trailing ``p`` and exponent." msgstr "" +"回傳浮點數的十六進位字串表示。對於有限浮點數,此表示方式總是包含一個前導 " +"``0x`` 及一個尾部 ``p`` 和指數。" #: ../../builtins/stdtypes.rst:697 msgid "" "Class method to return the float represented by a hexadecimal string *s*. " "The string *s* may have leading and trailing whitespace." msgstr "" +"Class method 回傳由十六進位字串 *s* 表示的浮點數。字串 *s* 可能有前導及尾部的" +"空白。" #: ../../builtins/stdtypes.rst:702 msgid "" "Note that :meth:`float.hex` is an instance method, while :meth:`float." "fromhex` is a class method." msgstr "" +"請注意 :meth:`float.hex` 是一個實例 method,而 :meth:`float.fromhex` 是一個 " +"class method。" #: ../../builtins/stdtypes.rst:705 msgid "A hexadecimal string takes the form::" -msgstr "" +msgstr "一個十六進位字串的形式如下: ::" #: ../../builtins/stdtypes.rst:707 msgid "[sign] ['0x'] integer ['.' fraction] ['p' exponent]" -msgstr "" +msgstr "[sign] ['0x'] integer ['.' fraction] ['p' exponent]" #: ../../builtins/stdtypes.rst:709 msgid "" @@ -1073,6 +1248,13 @@ msgid "" "by C's ``%a`` format character or Java's ``Double.toHexString`` are accepted " "by :meth:`float.fromhex`." msgstr "" +"其中可選的 ``sign`` 可以是 ``+`` 或 ``-``,``integer`` 和 ``fraction`` 是十六" +"進位數字的字串,而 ``exponent`` 是一個十進位整數並且有一個可選的前導符號。大" +"小寫不重要,並且整數或小數部分至少有一個十六進位數字。這個語法與 C99 標準的" +"第 6.4.4.2 節指定的語法相似,也與 Java 1.5 以後的語法相似。特別是 :meth:" +"`float.hex` 的輸出可用作 C 或 Java 程式碼中的十六進位浮點數文字,並且 C 的 " +"``%a`` 格式字元或 Java 的 ``Double.toHexString`` 產生的十六進位字串可被 :" +"meth:`float.fromhex` 接受。" #: ../../builtins/stdtypes.rst:722 msgid "" @@ -1081,28 +1263,36 @@ msgid "" "example, the hexadecimal string ``0x3.a7p10`` represents the floating-point " "number ``(3 + 10./16 + 7./16**2) * 2.0**10``, or ``3740.0``::" msgstr "" +"請注意指數是以十進位而非十六進位寫入,並且它給出了乘以係數的 2 的次方。例如," +"十六進位字串 ``0x3.a7p10`` 表示浮點數 ``(3 + 10./16 + 7./16**2) * 2.0**10``," +"或 ``3740.0``: ::" #: ../../builtins/stdtypes.rst:728 msgid "" ">>> float.fromhex('0x3.a7p10')\n" "3740.0" msgstr "" +">>> float.fromhex('0x3.a7p10')\n" +"3740.0" #: ../../builtins/stdtypes.rst:732 msgid "" "Applying the reverse conversion to ``3740.0`` gives a different hexadecimal " "string representing the same number::" msgstr "" +"對 ``3740.0`` 應用反向轉換會給出一個不同的十六進位字串,它表示相同的數字: ::" #: ../../builtins/stdtypes.rst:735 msgid "" ">>> float.hex(3740.0)\n" "'0x1.d380000000000p+11'" msgstr "" +">>> float.hex(3740.0)\n" +"'0x1.d380000000000p+11'" #: ../../builtins/stdtypes.rst:740 msgid "Additional Methods on Complex" -msgstr "" +msgstr "複數的附加方法" #: ../../builtins/stdtypes.rst:742 msgid "" @@ -1110,10 +1300,12 @@ msgid "" "`abstract base class`. :class:`!complex` also has the following additional " "methods." msgstr "" +":class:`!complex` 型別實作了 :class:`numbers.Complex` :term:`抽象基底類別 " +"`。:class:`!complex` 也有下列附加方法。" #: ../../builtins/stdtypes.rst:748 msgid "Class method to convert a number to a complex number." -msgstr "" +msgstr "將一個數字轉換為複數的類別方法。" #: ../../builtins/stdtypes.rst:750 msgid "" @@ -1122,10 +1314,14 @@ msgid "" "falls back to :meth:`~object.__float__`. If :meth:`!__float__` is not " "defined then it falls back to :meth:`~object.__index__`." msgstr "" +"對於任意 Python 物件 ``x``,``complex.from_number(x)`` 會委派給 ``x." +"__complex__()``。若 :meth:`~object.__complex__` 未定義,則會退回 :meth:" +"`~object.__float__`。若 :meth:`!__float__` 未定義,則會退回 :meth:`~object." +"__index__`。" #: ../../builtins/stdtypes.rst:761 msgid "Hashing of numeric types" -msgstr "" +msgstr "數值型別的雜湊" #: ../../builtins/stdtypes.rst:763 msgid "" @@ -1142,16 +1338,27 @@ msgid "" "value of ``P`` is made available to Python as the :attr:`~sys.hash_info." "modulus` attribute of :data:`sys.hash_info`." msgstr "" +"對於數字 ``x`` 和 ``y``,可能是不同型別,當 ``x == y`` 時,``hash(x) == " +"hash(y)`` 是一個要求( 詳見 :meth:`~object.__hash__` method 的文件以獲得更多" +"細節)。為了實作的便利性和效率跨越各種數值型別(包括 :class:`int`、:class:" +"`float`、:class:`decimal.Decimal` 和 :class:`fractions.Fraction`)Python 的數" +"值型別的雜湊是基於一個數學函式,它對於任何有理數都是定義的,因此適用於所有 :" +"class:`int` 和 :class:`fractions.Fraction` 的實例,以及所有有限的 :class:" +"`float` 和 :class:`decimal.Decimal` 的實例。基本上,這個函式是由簡化的 modulo" +"(模數) ``P`` 給出的一個固定的質數 ``P``。``P`` 的值作為 :data:`sys." +"hash_info` 的 :attr:`~sys.hash_info.modulus` 屬性提供給 Python。" #: ../../builtins/stdtypes.rst:778 msgid "" "Currently, the prime used is ``P = 2**31 - 1`` on machines with 32-bit C " "longs and ``P = 2**61 - 1`` on machines with 64-bit C longs." msgstr "" +"目前在具有 32 位元 C longs 的機器上所使用的質數是 ``P = 2**31 - 1``,而在具" +"有 64 位元 C longs 的機器上為 ``P = 2**61 - 1`` 。" #: ../../builtins/stdtypes.rst:781 msgid "Here are the rules in detail:" -msgstr "" +msgstr "以下是詳細的規則:" #: ../../builtins/stdtypes.rst:783 msgid "" @@ -1159,6 +1366,9 @@ msgid "" "by ``P``, define ``hash(x)`` as ``m * invmod(n, P) % P``, where ``invmod(n, " "P)`` gives the inverse of ``n`` modulo ``P``." msgstr "" +"如果 ``x = m / n`` 是一個非負的有理數,並且 ``n`` 不可被 ``P`` 整除,則將 " +"``hash(x)`` 定義為 ``m * invmod(n, P) % P``。其中 ``invmod(n, P)`` 為 ``n`` " +"對模數 ``P`` 的倒數。" #: ../../builtins/stdtypes.rst:787 msgid "" @@ -1167,12 +1377,17 @@ msgid "" "above doesn't apply; in this case define ``hash(x)`` to be the constant " "value ``sys.hash_info.inf``." msgstr "" +"如果 ``x = m / n`` 是一個非負的有理數,並且 ``n`` 可被 ``P`` 整除(但 ``m`` " +"不行),則 ``n`` 沒有 inverse modulo(模倒數) ``P`` ,並且不適用於上述規則;" +"在這種情況下,將 ``hash(x)`` 定義為常數值 ``sys.hash_info.inf``。" #: ../../builtins/stdtypes.rst:792 msgid "" "If ``x = m / n`` is a negative rational number define ``hash(x)`` as ``-" "hash(-x)``. If the resulting hash is ``-1``, replace it with ``-2``." msgstr "" +"如果 ``x = m / n`` 是一個負的有理數,則將 ``hash(x)`` 定義為 ``-hash(-x)``。" +"如果結果的雜湊是 ``-1``,則將其替換為 ``-2``。" #: ../../builtins/stdtypes.rst:796 msgid "" @@ -1180,6 +1395,8 @@ msgid "" "used as hash values for positive infinity or negative infinity " "(respectively)." msgstr "" +"特定值 ``sys.hash_info.inf`` 和 ``-sys.hash_info.inf`` (分別)被用作正無窮大" +"或負無窮大的雜湊值。" #: ../../builtins/stdtypes.rst:800 msgid "" @@ -1189,6 +1406,10 @@ msgid "" "lies in ``range(-2**(sys.hash_info.width - 1), 2**(sys.hash_info.width - " "1))``. Again, if the result is ``-1``, it's replaced with ``-2``." msgstr "" +"對於一個 :class:`complex` 值 ``z``,實部和虛部的雜湊值藉由 ``hash(z.real) + " +"sys.hash_info.imag * hash(z.imag)`` 的計算進行組合,對 ``2**sys.hash_info." +"width`` 取模數使其介於 ``range(-2**(sys.hash_info.width - 1), 2**(sys." +"hash_info.width - 1))``。同樣地,如果結果是 ``-1``,則將其替換為 ``-2``。" #: ../../builtins/stdtypes.rst:808 msgid "" @@ -1196,6 +1417,8 @@ msgid "" "the built-in hash, for computing the hash of a rational number, :class:" "`float`, or :class:`complex`::" msgstr "" +"為了闡明上述規則,這裡有一些 Python 程式碼範例,等同於內建的雜湊,用於計算有" +"理數、:class:`float` 或 :class:`complex` 的雜湊: ::" #: ../../builtins/stdtypes.rst:813 msgid "" @@ -1248,22 +1471,73 @@ msgid "" " hash_value = -2\n" " return hash_value" msgstr "" +"import sys, math\n" +"\n" +"def hash_fraction(m, n):\n" +" \"\"\"Compute the hash of a rational number m / n.\n" +"\n" +" Assumes m and n are integers, with n positive.\n" +" Equivalent to hash(fractions.Fraction(m, n)).\n" +"\n" +" \"\"\"\n" +" P = sys.hash_info.modulus\n" +" # 去除 P 的公因數。(但若 m 和 n 互質則不需要這一步)\n" +" while m % P == n % P == 0:\n" +" m, n = m // P, n // P\n" +"\n" +" if n % P == 0:\n" +" hash_value = sys.hash_info.inf\n" +" else:\n" +" # 費馬小定理: pow(n, P-1, P) 是 1, 所以\n" +" # pow(n, P-2, P) 會得到 n modulo P 的反元素。\n" +" hash_value = (abs(m) % P) * pow(n, P - 2, P) % P\n" +" if m < 0:\n" +" hash_value = -hash_value\n" +" if hash_value == -1:\n" +" hash_value = -2\n" +" return hash_value\n" +"\n" +"def hash_float(x):\n" +" \"\"\"Compute the hash of a float x.\"\"\"\n" +"\n" +" if math.isnan(x):\n" +" return object.__hash__(x)\n" +" elif math.isinf(x):\n" +" return sys.hash_info.inf if x > 0 else -sys.hash_info.inf\n" +" else:\n" +" return hash_fraction(*x.as_integer_ratio())\n" +"\n" +"def hash_complex(z):\n" +" \"\"\"Compute the hash of a complex number z.\"\"\"\n" +"\n" +" hash_value = hash_float(z.real) + sys.hash_info.imag * hash_float(z." +"imag)\n" +" # 對 2**sys.hash_info.width 做 signed reduction modulo\n" +" M = 2**(sys.hash_info.width - 1)\n" +" hash_value = (hash_value & (M - 1)) - (hash_value & M)\n" +" if hash_value == -1:\n" +" hash_value = -2\n" +" return hash_value" #: ../../builtins/stdtypes.rst:864 msgid "Boolean Type - :class:`bool`" -msgstr "" +msgstr "Boolean 型別 - :class:`bool`" #: ../../builtins/stdtypes.rst:866 msgid "" "Booleans represent truth values. The :class:`bool` type has exactly two " "constant instances: ``True`` and ``False``." msgstr "" +"Boolean 值代表 truth values(真值)。:class:`bool` 型別有兩個常數實例:" +"``True`` 和 ``False``。" #: ../../builtins/stdtypes.rst:874 msgid "" "The built-in function :func:`bool` converts any value to a boolean, if the " "value can be interpreted as a truth value (see section :ref:`truth` above)." msgstr "" +"內建函式 :func:`bool` 將任何值轉換為 boolean 值,如果該值可以被直譯為一個 " +"truth value(真值)(見上面的\\ :ref:`truth`\\ 章節)。" #: ../../builtins/stdtypes.rst:877 msgid "" @@ -1273,12 +1547,16 @@ msgid "" "\"and\", \"or\", \"xor\". However, the logical operators ``and``, ``or`` and " "``!=`` should be preferred over ``&``, ``|`` and ``^``." msgstr "" +"對於邏輯運算,使用 :ref:`boolean 運算子 ` ``and``、``or`` 和 " +"``not``。當將位元運算子 ``&``、``|``、``^`` 應用於兩個 boolean 值時,它們會回" +"傳一個等同於邏輯運算 \"and\"、\"or\"、\"xor\" 的 boolean 值。然而,應該優先使" +"用邏輯運算子 ``and``、``or`` 和 ``!=`` 而不是 ``&``、``|`` 和 ``^``。" #: ../../builtins/stdtypes.rst:886 msgid "" "The use of the bitwise inversion operator ``~`` is deprecated and will raise " "an error in Python 3.16." -msgstr "" +msgstr "位元反轉運算子 ``~`` 的使用已被棄用並且將在 Python 3.16 中引發錯誤。" #: ../../builtins/stdtypes.rst:889 msgid "" @@ -1287,10 +1565,13 @@ msgid "" "1, respectively. However, relying on this is discouraged; explicitly convert " "using :func:`int` instead." msgstr "" +":class:`bool` 是 :class:`int` 的子類別(見\\ :ref:`typesnumeric`)。在許多數" +"值情境中,``False`` 和 ``True`` 分別像整數 0 和 1 一樣。然而,不鼓勵依賴這一" +"點;請使用 :func:`int` 進行顯式轉換。" #: ../../builtins/stdtypes.rst:897 msgid "Iterator Types" -msgstr "" +msgstr "疊代器型別" #: ../../builtins/stdtypes.rst:905 msgid "" @@ -1299,12 +1580,16 @@ msgid "" "support iteration. Sequences, described below in more detail, always " "support the iteration methods." msgstr "" +"Python 支援對容器的疊代概念。這是實作兩種不同的 methods;這些方法被用於允許使" +"用者定義的 classes 以支援疊代。序列則總是支援這些疊代 methods,在下方有更詳細" +"的描述。" #: ../../builtins/stdtypes.rst:910 msgid "" "One method needs to be defined for container objects to provide :term:" "`iterable` support:" msgstr "" +"需要為容器物件定義一個 method 來提供\\ :term:`可疊代物件 `\\ 支援:" #: ../../builtins/stdtypes.rst:917 msgid "" @@ -1317,12 +1602,18 @@ msgid "" "member:`~PyTypeObject.tp_iter` slot of the type structure for Python objects " "in the Python/C API." msgstr "" +"回傳一個\\ :term:`疊代器 `\\ 物件。該物件需要支援下述的疊代器協定。" +"如果一個容器支援不同型別的疊代,則可以提供額外的 methods 來專門請求這些疊代型" +"別的疊代器。(支援多種形式疊代的物件的一個例子是支援廣度優先和深度優先遍歷的" +"樹結構。)此 method 對應 Python/C API 中 Python 物件的型別結構的 :c:member:" +"`~PyTypeObject.tp_iter` 插槽。" #: ../../builtins/stdtypes.rst:926 msgid "" "The iterator objects themselves are required to support the following two " "methods, which together form the :dfn:`iterator protocol`:" msgstr "" +"疊代器物件本身需要支援下列兩個 methods,他們一起形成了 :dfn:`疊代器協定`:" #: ../../builtins/stdtypes.rst:932 msgid "" @@ -1331,6 +1622,9 @@ msgid "" "`in` statements. This method corresponds to the :c:member:`~PyTypeObject." "tp_iter` slot of the type structure for Python objects in the Python/C API." msgstr "" +"回傳\\ :term:`疊代器 `\\ 物件本身。這是為了允許容器和疊代器都可以" +"與 :keyword:`for` 和 :keyword:`in` 在陳述式中使用。此 method 對應於 Python/C " +"API 中 Python 物件的型別結構的 :c:member:`~PyTypeObject.tp_iter` 插槽。" #: ../../builtins/stdtypes.rst:941 msgid "" @@ -1339,6 +1633,9 @@ msgid "" "the :c:member:`~PyTypeObject.tp_iternext` slot of the type structure for " "Python objects in the Python/C API." msgstr "" +"從\\ :term:`疊代器 `\\ 回傳下一個項目。如果沒有更多項目,則引發 :" +"exc:`StopIteration` 例外。此 method 對應於 Python/C API 中Python 物件的型別結" +"構的 :c:member:`~PyTypeObject.tp_iternext` 插槽。" #: ../../builtins/stdtypes.rst:946 msgid "" @@ -1347,6 +1644,8 @@ msgid "" "forms. The specific types are not important beyond their implementation of " "the iterator protocol." msgstr "" +"Python 定義了幾個疊代器物件來支援對一般和特定序列型別、字典和其他更專門的形式" +"的疊代。這些特定型別除了實作疊代器協定外並不重要。" #: ../../builtins/stdtypes.rst:951 msgid "" @@ -1354,6 +1653,8 @@ msgid "" "`StopIteration`, it must continue to do so on subsequent calls. " "Implementations that do not obey this property are deemed broken." msgstr "" +"一旦疊代器的 :meth:`~iterator.__next__` method 引發 :exc:`StopIteration`,則" +"它必須在後續呼叫中繼續這樣做。不遵守此屬性的實作被認為是有問題的。" #: ../../builtins/stdtypes.rst:959 msgid "Generator Types" @@ -1413,63 +1714,63 @@ msgstr "" #: ../../builtins/stdtypes.rst:1002 msgid "" "See :ref:`time-complexity` for the costs of the various sequence operations." -msgstr "" +msgstr "各種序列操作的成本請參閱\\ :ref:`time-complexity`\\ 。" #: ../../builtins/stdtypes.rst:1020 msgid "``x in s``" -msgstr "" +msgstr "``x in s``" #: ../../builtins/stdtypes.rst:1020 msgid "``True`` if an item of *s* is equal to *x*, else ``False``" -msgstr "" +msgstr "如果 *s* 的一個項目等於 *x* 則為 ``True``,否則為 ``False``" #: ../../builtins/stdtypes.rst:1023 msgid "``x not in s``" -msgstr "" +msgstr "``x not in s``" #: ../../builtins/stdtypes.rst:1023 msgid "``False`` if an item of *s* is equal to *x*, else ``True``" -msgstr "" +msgstr "如果 *s* 的一個項目等於 *x* 則為 ``False``,否則為 ``True``" #: ../../builtins/stdtypes.rst:1026 msgid "``s + t``" -msgstr "" +msgstr "``s + t``" #: ../../builtins/stdtypes.rst:1026 msgid "the concatenation of *s* and *t*" -msgstr "" +msgstr "*s* 和 *t* 的串接" #: ../../builtins/stdtypes.rst:1026 msgid "(6)(7)" -msgstr "" +msgstr "(6)(7)" #: ../../builtins/stdtypes.rst:1029 msgid "``s * n`` or ``n * s``" -msgstr "" +msgstr "``s * n`` 或 ``n * s``" #: ../../builtins/stdtypes.rst:1029 msgid "equivalent to adding *s* to itself *n* times" -msgstr "" +msgstr "等同於將 *s* 加到自己 *n* 次" #: ../../builtins/stdtypes.rst:1029 msgid "(2)(7)" -msgstr "" +msgstr "(2)(7)" #: ../../builtins/stdtypes.rst:1032 msgid "``s[i]``" -msgstr "" +msgstr "``s[i]``" #: ../../builtins/stdtypes.rst:1032 msgid "*i*\\ th item of *s*, origin 0" -msgstr "" +msgstr "*s* 的第 *i* 項,起始為 0" #: ../../builtins/stdtypes.rst:1032 msgid "(3)(8)" -msgstr "" +msgstr "(3)(8)" #: ../../builtins/stdtypes.rst:1034 msgid "``s[i:j]``" -msgstr "" +msgstr "``s[i:j]``" #: ../../builtins/stdtypes.rst:1034 msgid "slice of *s* from *i* to *j*" @@ -1477,11 +1778,11 @@ msgstr "" #: ../../builtins/stdtypes.rst:1034 msgid "(3)(4)" -msgstr "" +msgstr "(3)(4)" #: ../../builtins/stdtypes.rst:1036 msgid "``s[i:j:k]``" -msgstr "" +msgstr "``s[i:j:k]``" #: ../../builtins/stdtypes.rst:1036 msgid "slice of *s* from *i* to *j* with step *k*" @@ -1489,31 +1790,31 @@ msgstr "" #: ../../builtins/stdtypes.rst:1036 msgid "(3)(5)" -msgstr "" +msgstr "(3)(5)" #: ../../builtins/stdtypes.rst:1039 msgid "``len(s)``" -msgstr "" +msgstr "``len(s)``" #: ../../builtins/stdtypes.rst:1039 msgid "length of *s*" -msgstr "" +msgstr "*s* 的長度" #: ../../builtins/stdtypes.rst:1041 msgid "``min(s)``" -msgstr "" +msgstr "``min(s)``" #: ../../builtins/stdtypes.rst:1041 msgid "smallest item of *s*" -msgstr "" +msgstr "*s* 中最小的項目" #: ../../builtins/stdtypes.rst:1043 msgid "``max(s)``" -msgstr "" +msgstr "``max(s)``" #: ../../builtins/stdtypes.rst:1043 msgid "largest item of *s*" -msgstr "" +msgstr "*s* 中最大的項目" #: ../../builtins/stdtypes.rst:1046 msgid "" @@ -1546,6 +1847,8 @@ msgid "" ">>> \"gg\" in \"eggs\"\n" "True" msgstr "" +">>> \"gg\" in \"eggs\"\n" +"True" #: ../../builtins/stdtypes.rst:1074 msgid "" @@ -1564,8 +1867,14 @@ msgid "" ">>> lists\n" "[[3], [3], [3]]" msgstr "" - -#: ../../builtins/stdtypes.rst:1086 +">>> lists = [[]] * 3\n" +">>> lists\n" +"[[], [], []]\n" +">>> lists[0].append(3)\n" +">>> lists\n" +"[[3], [3], [3]]" + +#: ../../builtins/stdtypes.rst:1086 msgid "" "What has happened is that ``[[]]`` is a one-element list containing an empty " "list, so all three elements of ``[[]] * 3`` are references to this single " @@ -1582,6 +1891,12 @@ msgid "" ">>> lists\n" "[[3], [5], [7]]" msgstr "" +">>> lists = [[] for i in range(3)]\n" +">>> lists[0].append(3)\n" +">>> lists[1].append(5)\n" +">>> lists[2].append(7)\n" +">>> lists\n" +"[[3], [5], [7]]" #: ../../builtins/stdtypes.rst:1098 msgid "" @@ -1604,23 +1919,23 @@ msgstr "" #: ../../builtins/stdtypes.rst:1110 msgid "If *i* is omitted or ``None``, use ``0``." -msgstr "" +msgstr "假如 *i* 被省略或為 ``None``,則使用 ``0``。" #: ../../builtins/stdtypes.rst:1111 msgid "If *j* is omitted or ``None``, use ``len(s)``." -msgstr "" +msgstr "假如 *j* 被省略或為 ``None``,則使用 ``len(s)``。" #: ../../builtins/stdtypes.rst:1112 msgid "If *i* or *j* is less than ``-len(s)``, use ``0``." -msgstr "" +msgstr "假如 *i* 或 *j* 小於 ``-len(s)``,則使用 ``0``。" #: ../../builtins/stdtypes.rst:1113 msgid "If *i* or *j* is greater than ``len(s)``, use ``len(s)``." -msgstr "" +msgstr "假如 *i* 或 *j* 大於 ``len(s)``,則使用 ``len(s)``。" #: ../../builtins/stdtypes.rst:1114 msgid "If *i* is greater than or equal to *j*, the slice is empty." -msgstr "" +msgstr "假如 *i* 大於或等於 *j*,則該切片為空。" #: ../../builtins/stdtypes.rst:1117 msgid "" @@ -1679,23 +1994,23 @@ msgstr "" #: ../../builtins/stdtypes.rst:1158 msgid "Sequence Methods" -msgstr "" +msgstr "序列方法" #: ../../builtins/stdtypes.rst:1159 msgid "Sequence types also support the following methods:" -msgstr "" +msgstr "序列型別也支援以下方法:" #: ../../builtins/stdtypes.rst:1169 msgid "Return the total number of occurrences of *value* in *sequence*." -msgstr "" +msgstr "回傳 *sequence* 中 *value* 出現的總次數。" #: ../../builtins/stdtypes.rst:1179 msgid "Return the index of the first occurrence of *value* in *sequence*." -msgstr "" +msgstr "回傳 *sequence* 中 *value* 首次出現的索引。" #: ../../builtins/stdtypes.rst:1181 ../../builtins/stdtypes.rst:1365 msgid "Raises :exc:`ValueError` if *value* is not found in *sequence*." -msgstr "" +msgstr "當 *value* 不在 *sequence* 中時引發 :exc:`ValueError`。" #: ../../builtins/stdtypes.rst:1183 msgid "" @@ -1712,7 +2027,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:1195 msgid "Immutable Sequence Types" -msgstr "" +msgstr "不可變序列型別" #: ../../builtins/stdtypes.rst:1202 msgid "" @@ -1736,7 +2051,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:1217 msgid "Mutable Sequence Types" -msgstr "" +msgstr "可變序列型別" #: ../../builtins/stdtypes.rst:1224 msgid "" @@ -1755,7 +2070,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:1244 msgid "``s[i] = x``" -msgstr "" +msgstr "``s[i] = x``" #: ../../builtins/stdtypes.rst:1244 msgid "item *i* of *s* is replaced by *x*" @@ -1763,15 +2078,15 @@ msgstr "" #: ../../builtins/stdtypes.rst:1247 msgid "``del s[i]``" -msgstr "" +msgstr "``del s[i]``" #: ../../builtins/stdtypes.rst:1247 msgid "removes item *i* of *s*" -msgstr "" +msgstr "移除 *s* 中的項目 *i*" #: ../../builtins/stdtypes.rst:1249 msgid "``s[i:j] = t``" -msgstr "" +msgstr "``s[i:j] = t``" #: ../../builtins/stdtypes.rst:1249 msgid "" @@ -1780,32 +2095,32 @@ msgstr "" #: ../../builtins/stdtypes.rst:1253 msgid "``del s[i:j]``" -msgstr "" +msgstr "``del s[i:j]``" #: ../../builtins/stdtypes.rst:1253 msgid "" "removes the elements of ``s[i:j]`` from the list (same as ``s[i:j] = []``)" -msgstr "" +msgstr "移除串列中 ``s[i:j]`` 的元素(和 ``s[i:j] = []`` 相同)" #: ../../builtins/stdtypes.rst:1257 msgid "``s[i:j:k] = t``" -msgstr "" +msgstr "``s[i:j:k] = t``" #: ../../builtins/stdtypes.rst:1257 msgid "the elements of ``s[i:j:k]`` are replaced by those of *t*" -msgstr "" +msgstr "``s[i:j:k]`` 的元素被 *t* 的元素取代" #: ../../builtins/stdtypes.rst:1260 msgid "``del s[i:j:k]``" -msgstr "" +msgstr "``del s[i:j:k]``" #: ../../builtins/stdtypes.rst:1260 msgid "removes the elements of ``s[i:j:k]`` from the list" -msgstr "" +msgstr "移除串列中 ``s[i:j:k]`` 的元素" #: ../../builtins/stdtypes.rst:1263 msgid "``s += t``" -msgstr "" +msgstr "``s += t``" #: ../../builtins/stdtypes.rst:1263 msgid "" @@ -1815,7 +2130,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:1268 msgid "``s *= n``" -msgstr "" +msgstr "``s *= n``" #: ../../builtins/stdtypes.rst:1268 msgid "updates *s* with its contents repeated *n* times" @@ -1837,29 +2152,30 @@ msgstr "" #: ../../builtins/stdtypes.rst:1284 msgid "Mutable Sequence Methods" -msgstr "" +msgstr "可變序列方法" #: ../../builtins/stdtypes.rst:1285 msgid "Mutable sequence types also support the following methods:" -msgstr "" +msgstr "可變序列型別也支援以下方法:" #: ../../builtins/stdtypes.rst:1294 msgid "" "Append *value* to the end of the sequence. This is equivalent to writing " "``seq[len(seq):len(seq)] = [value]``." msgstr "" +"將 *value* 附加到序列末尾,這和 ``seq[len(seq):len(seq)] = [value]`` 相同。" #: ../../builtins/stdtypes.rst:1306 msgid "" "Remove all items from *sequence*. This is equivalent to writing ``del " "sequence[:]``." -msgstr "" +msgstr "移除 *sequence* 中的所有項目,這和 ``del sequence[:]`` 相同。" #: ../../builtins/stdtypes.rst:1318 msgid "" "Create a shallow copy of *sequence*. This is equivalent to writing " "``sequence[:]``." -msgstr "" +msgstr "建立 *sequence* 的淺層複製,這和 ``sequence[:]`` 相同。" #: ../../builtins/stdtypes.rst:1321 msgid "" @@ -1885,6 +2201,8 @@ msgid "" "Retrieve the item at *index* and also remove it from *sequence*. By default, " "the last item in *sequence* is removed and returned." msgstr "" +"取出 *sequence* 中位於 *index* 的項目並將其從 *sequence* 中移除。預設情況下," +"會移除並回傳 *sequence* 中的最後一個項目。" #: ../../builtins/stdtypes.rst:1363 msgid "Remove the first item from *sequence* where ``sequence[i] == value``." @@ -1899,7 +2217,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:1382 msgid "Lists" -msgstr "" +msgstr "List(串列)" #: ../../builtins/stdtypes.rst:1386 msgid "" @@ -1923,11 +2241,11 @@ msgstr "" #: ../../builtins/stdtypes.rst:1396 msgid "Using a list comprehension: ``[x for x in iterable]``" -msgstr "" +msgstr "使用串列綜合運算式:``[x for x in iterable]``" #: ../../builtins/stdtypes.rst:1397 msgid "Using the type constructor: ``list()`` or ``list(iterable)``" -msgstr "" +msgstr "使用型別建構函式:``list()`` 或 ``list(iterable)``" #: ../../builtins/stdtypes.rst:1399 msgid "" @@ -2029,7 +2347,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:1468 msgid "Tuples" -msgstr "" +msgstr "Tuple(元組)" #: ../../builtins/stdtypes.rst:1472 msgid "" @@ -2042,19 +2360,19 @@ msgstr "" #: ../../builtins/stdtypes.rst:1480 msgid "Tuples may be constructed in a number of ways:" -msgstr "" +msgstr "元組可以以多種方式建構:" #: ../../builtins/stdtypes.rst:1482 msgid "Using a pair of parentheses to denote the empty tuple: ``()``" -msgstr "" +msgstr "使用一對圓括號表示空元組:``()``" #: ../../builtins/stdtypes.rst:1483 msgid "Using a trailing comma for a singleton tuple: ``a,`` or ``(a,)``" -msgstr "" +msgstr "使用末尾的逗號表示單元素元組:``a,`` 或 ``(a,)``" #: ../../builtins/stdtypes.rst:1484 msgid "Separating items with commas: ``a, b, c`` or ``(a, b, c)``" -msgstr "" +msgstr "使用逗號分隔項目:``a, b, c`` 或 ``(a, b, c)``" #: ../../builtins/stdtypes.rst:1485 msgid "Using the :func:`tuple` built-in: ``tuple()`` or ``tuple(iterable)``" @@ -2167,6 +2485,20 @@ msgid "" ">>> list(range(1, 0))\n" "[]" msgstr "" +">>> list(range(10))\n" +"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n" +">>> list(range(1, 11))\n" +"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n" +">>> list(range(0, 30, 5))\n" +"[0, 5, 10, 15, 20, 25]\n" +">>> list(range(0, 10, 3))\n" +"[0, 3, 6, 9]\n" +">>> list(range(0, -10, -1))\n" +"[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n" +">>> list(range(0))\n" +"[]\n" +">>> list(range(1, 0))\n" +"[]" #: ../../builtins/stdtypes.rst:1567 msgid "" @@ -2256,387 +2588,387 @@ msgstr "" #: ../../builtins/stdtypes.rst:1653 msgid "Category" -msgstr "" +msgstr "分類" #: ../../builtins/stdtypes.rst:1653 msgid ":class:`str` methods" -msgstr "" +msgstr ":class:`str` 方法" #: ../../builtins/stdtypes.rst:1653 msgid ":class:`bytes` and :class:`bytearray` methods" -msgstr "" +msgstr ":class:`bytes` 和 :class:`bytearray` 方法" #: ../../builtins/stdtypes.rst:1655 msgid "Formatting" -msgstr "" +msgstr "格式化" #: ../../builtins/stdtypes.rst:1655 msgid ":meth:`str.format`" -msgstr "" +msgstr ":meth:`str.format`" #: ../../builtins/stdtypes.rst:1657 msgid ":meth:`str.format_map`" -msgstr "" +msgstr ":meth:`str.format_map`" #: ../../builtins/stdtypes.rst:1659 msgid ":ref:`f-strings`" -msgstr "" +msgstr ":ref:`f-strings`" #: ../../builtins/stdtypes.rst:1661 msgid ":ref:`old-string-formatting`" -msgstr "" +msgstr ":ref:`old-string-formatting`" #: ../../builtins/stdtypes.rst:1661 msgid ":ref:`bytes-formatting`" -msgstr "" +msgstr ":ref:`bytes-formatting`" #: ../../builtins/stdtypes.rst:1663 msgid "Searching and Replacing" -msgstr "" +msgstr "搜尋和取代" #: ../../builtins/stdtypes.rst:1663 msgid ":meth:`str.find`" -msgstr "" +msgstr ":meth:`str.find`" #: ../../builtins/stdtypes.rst:1663 msgid ":meth:`str.rfind`" -msgstr "" +msgstr ":meth:`str.rfind`" #: ../../builtins/stdtypes.rst:1663 msgid ":meth:`bytes.find`" -msgstr "" +msgstr ":meth:`bytes.find`" #: ../../builtins/stdtypes.rst:1663 msgid ":meth:`bytes.rfind`" -msgstr "" +msgstr ":meth:`bytes.rfind`" #: ../../builtins/stdtypes.rst:1665 msgid ":meth:`str.index`" -msgstr "" +msgstr ":meth:`str.index`" #: ../../builtins/stdtypes.rst:1665 msgid ":meth:`str.rindex`" -msgstr "" +msgstr ":meth:`str.rindex`" #: ../../builtins/stdtypes.rst:1665 msgid ":meth:`bytes.index`" -msgstr "" +msgstr ":meth:`bytes.index`" #: ../../builtins/stdtypes.rst:1665 msgid ":meth:`bytes.rindex`" -msgstr "" +msgstr ":meth:`bytes.rindex`" #: ../../builtins/stdtypes.rst:1667 msgid ":meth:`str.startswith`" -msgstr "" +msgstr ":meth:`str.startswith`" #: ../../builtins/stdtypes.rst:1667 msgid ":meth:`bytes.startswith`" -msgstr "" +msgstr ":meth:`bytes.startswith`" #: ../../builtins/stdtypes.rst:1669 msgid ":meth:`str.endswith`" -msgstr "" +msgstr ":meth:`str.endswith`" #: ../../builtins/stdtypes.rst:1669 msgid ":meth:`bytes.endswith`" -msgstr "" +msgstr ":meth:`bytes.endswith`" #: ../../builtins/stdtypes.rst:1671 msgid ":meth:`str.count`" -msgstr "" +msgstr ":meth:`str.count`" #: ../../builtins/stdtypes.rst:1671 msgid ":meth:`bytes.count`" -msgstr "" +msgstr ":meth:`bytes.count`" #: ../../builtins/stdtypes.rst:1673 msgid ":meth:`str.replace`" -msgstr "" +msgstr ":meth:`str.replace`" #: ../../builtins/stdtypes.rst:1673 msgid ":meth:`bytes.replace`" -msgstr "" +msgstr ":meth:`bytes.replace`" #: ../../builtins/stdtypes.rst:1675 msgid "Splitting and Joining" -msgstr "" +msgstr "分割和連接" #: ../../builtins/stdtypes.rst:1675 msgid ":meth:`str.split`" -msgstr "" +msgstr ":meth:`str.split`" #: ../../builtins/stdtypes.rst:1675 msgid ":meth:`str.rsplit`" -msgstr "" +msgstr ":meth:`str.rsplit`" #: ../../builtins/stdtypes.rst:1675 msgid ":meth:`bytes.split`" -msgstr "" +msgstr ":meth:`bytes.split`" #: ../../builtins/stdtypes.rst:1675 msgid ":meth:`bytes.rsplit`" -msgstr "" +msgstr ":meth:`bytes.rsplit`" #: ../../builtins/stdtypes.rst:1677 msgid ":meth:`str.splitlines`" -msgstr "" +msgstr ":meth:`str.splitlines`" #: ../../builtins/stdtypes.rst:1677 msgid ":meth:`bytes.splitlines`" -msgstr "" +msgstr ":meth:`bytes.splitlines`" #: ../../builtins/stdtypes.rst:1679 msgid ":meth:`str.partition`" -msgstr "" +msgstr ":meth:`str.partition`" #: ../../builtins/stdtypes.rst:1679 msgid ":meth:`bytes.partition`" -msgstr "" +msgstr ":meth:`bytes.partition`" #: ../../builtins/stdtypes.rst:1681 msgid ":meth:`str.rpartition`" -msgstr "" +msgstr ":meth:`str.rpartition`" #: ../../builtins/stdtypes.rst:1681 msgid ":meth:`bytes.rpartition`" -msgstr "" +msgstr ":meth:`bytes.rpartition`" #: ../../builtins/stdtypes.rst:1683 msgid ":meth:`str.join`" -msgstr "" +msgstr ":meth:`str.join`" #: ../../builtins/stdtypes.rst:1683 msgid ":meth:`bytes.join`" -msgstr "" +msgstr ":meth:`bytes.join`" #: ../../builtins/stdtypes.rst:1685 msgid "String Classification" -msgstr "" +msgstr "字串分類" #: ../../builtins/stdtypes.rst:1685 msgid ":meth:`str.isalpha`" -msgstr "" +msgstr ":meth:`str.isalpha`" #: ../../builtins/stdtypes.rst:1685 msgid ":meth:`bytes.isalpha`" -msgstr "" +msgstr ":meth:`bytes.isalpha`" #: ../../builtins/stdtypes.rst:1687 msgid ":meth:`str.isdecimal`" -msgstr "" +msgstr ":meth:`str.isdecimal`" #: ../../builtins/stdtypes.rst:1689 msgid ":meth:`str.isdigit`" -msgstr "" +msgstr ":meth:`str.isdigit`" #: ../../builtins/stdtypes.rst:1689 msgid ":meth:`bytes.isdigit`" -msgstr "" +msgstr ":meth:`bytes.isdigit`" #: ../../builtins/stdtypes.rst:1691 msgid ":meth:`str.isnumeric`" -msgstr "" +msgstr ":meth:`str.isnumeric`" #: ../../builtins/stdtypes.rst:1693 msgid ":meth:`str.isalnum`" -msgstr "" +msgstr ":meth:`str.isalnum`" #: ../../builtins/stdtypes.rst:1693 msgid ":meth:`bytes.isalnum`" -msgstr "" +msgstr ":meth:`bytes.isalnum`" #: ../../builtins/stdtypes.rst:1695 msgid ":meth:`str.isidentifier`" -msgstr "" +msgstr ":meth:`str.isidentifier`" #: ../../builtins/stdtypes.rst:1697 msgid ":meth:`str.islower`" -msgstr "" +msgstr ":meth:`str.islower`" #: ../../builtins/stdtypes.rst:1697 msgid ":meth:`bytes.islower`" -msgstr "" +msgstr ":meth:`bytes.islower`" #: ../../builtins/stdtypes.rst:1699 msgid ":meth:`str.isupper`" -msgstr "" +msgstr ":meth:`str.isupper`" #: ../../builtins/stdtypes.rst:1699 msgid ":meth:`bytes.isupper`" -msgstr "" +msgstr ":meth:`bytes.isupper`" #: ../../builtins/stdtypes.rst:1701 msgid ":meth:`str.istitle`" -msgstr "" +msgstr ":meth:`str.istitle`" #: ../../builtins/stdtypes.rst:1701 msgid ":meth:`bytes.istitle`" -msgstr "" +msgstr ":meth:`bytes.istitle`" #: ../../builtins/stdtypes.rst:1703 msgid ":meth:`str.isspace`" -msgstr "" +msgstr ":meth:`str.isspace`" #: ../../builtins/stdtypes.rst:1703 msgid ":meth:`bytes.isspace`" -msgstr "" +msgstr ":meth:`bytes.isspace`" #: ../../builtins/stdtypes.rst:1705 msgid ":meth:`str.isprintable`" -msgstr "" +msgstr ":meth:`str.isprintable`" #: ../../builtins/stdtypes.rst:1707 msgid "Case Manipulation" -msgstr "" +msgstr "大小寫操作" #: ../../builtins/stdtypes.rst:1707 msgid ":meth:`str.lower`" -msgstr "" +msgstr ":meth:`str.lower`" #: ../../builtins/stdtypes.rst:1707 msgid ":meth:`bytes.lower`" -msgstr "" +msgstr ":meth:`bytes.lower`" #: ../../builtins/stdtypes.rst:1709 msgid ":meth:`str.upper`" -msgstr "" +msgstr ":meth:`str.upper`" #: ../../builtins/stdtypes.rst:1709 msgid ":meth:`bytes.upper`" -msgstr "" +msgstr ":meth:`bytes.upper`" #: ../../builtins/stdtypes.rst:1711 msgid ":meth:`str.casefold`" -msgstr "" +msgstr ":meth:`str.casefold`" #: ../../builtins/stdtypes.rst:1713 msgid ":meth:`str.capitalize`" -msgstr "" +msgstr ":meth:`str.capitalize`" #: ../../builtins/stdtypes.rst:1713 msgid ":meth:`bytes.capitalize`" -msgstr "" +msgstr ":meth:`bytes.capitalize`" #: ../../builtins/stdtypes.rst:1715 msgid ":meth:`str.title`" -msgstr "" +msgstr ":meth:`str.title`" #: ../../builtins/stdtypes.rst:1715 msgid ":meth:`bytes.title`" -msgstr "" +msgstr ":meth:`bytes.title`" #: ../../builtins/stdtypes.rst:1717 msgid ":meth:`str.swapcase`" -msgstr "" +msgstr ":meth:`str.swapcase`" #: ../../builtins/stdtypes.rst:1717 msgid ":meth:`bytes.swapcase`" -msgstr "" +msgstr ":meth:`bytes.swapcase`" #: ../../builtins/stdtypes.rst:1719 msgid "Padding and Stripping" -msgstr "" +msgstr "填充和去除空白" #: ../../builtins/stdtypes.rst:1719 msgid ":meth:`str.ljust`" -msgstr "" +msgstr ":meth:`str.ljust`" #: ../../builtins/stdtypes.rst:1719 msgid ":meth:`str.rjust`" -msgstr "" +msgstr ":meth:`str.rjust`" #: ../../builtins/stdtypes.rst:1719 msgid ":meth:`bytes.ljust`" -msgstr "" +msgstr ":meth:`bytes.ljust`" #: ../../builtins/stdtypes.rst:1719 msgid ":meth:`bytes.rjust`" -msgstr "" +msgstr ":meth:`bytes.rjust`" #: ../../builtins/stdtypes.rst:1721 msgid ":meth:`str.center`" -msgstr "" +msgstr ":meth:`str.center`" #: ../../builtins/stdtypes.rst:1721 msgid ":meth:`bytes.center`" -msgstr "" +msgstr ":meth:`bytes.center`" #: ../../builtins/stdtypes.rst:1723 msgid ":meth:`str.expandtabs`" -msgstr "" +msgstr ":meth:`str.expandtabs`" #: ../../builtins/stdtypes.rst:1723 msgid ":meth:`bytes.expandtabs`" -msgstr "" +msgstr ":meth:`bytes.expandtabs`" #: ../../builtins/stdtypes.rst:1725 msgid ":meth:`str.strip`" -msgstr "" +msgstr ":meth:`str.strip`" #: ../../builtins/stdtypes.rst:1725 msgid ":meth:`bytes.strip`" -msgstr "" +msgstr ":meth:`bytes.strip`" #: ../../builtins/stdtypes.rst:1727 msgid ":meth:`str.lstrip`" -msgstr "" +msgstr ":meth:`str.lstrip`" #: ../../builtins/stdtypes.rst:1727 msgid ":meth:`str.rstrip`" -msgstr "" +msgstr ":meth:`str.rstrip`" #: ../../builtins/stdtypes.rst:1727 msgid ":meth:`bytes.lstrip`" -msgstr "" +msgstr ":meth:`bytes.lstrip`" #: ../../builtins/stdtypes.rst:1727 msgid ":meth:`bytes.rstrip`" -msgstr "" +msgstr ":meth:`bytes.rstrip`" #: ../../builtins/stdtypes.rst:1729 msgid ":meth:`str.removeprefix`" -msgstr "" +msgstr ":meth:`str.removeprefix`" #: ../../builtins/stdtypes.rst:1729 msgid ":meth:`bytes.removeprefix`" -msgstr "" +msgstr ":meth:`bytes.removeprefix`" #: ../../builtins/stdtypes.rst:1731 msgid ":meth:`str.removesuffix`" -msgstr "" +msgstr ":meth:`str.removesuffix`" #: ../../builtins/stdtypes.rst:1731 msgid ":meth:`bytes.removesuffix`" -msgstr "" +msgstr ":meth:`bytes.removesuffix`" #: ../../builtins/stdtypes.rst:1733 msgid "Translation and Encoding" -msgstr "" +msgstr "翻譯和編碼" #: ../../builtins/stdtypes.rst:1733 msgid ":meth:`str.translate`" -msgstr "" +msgstr ":meth:`str.translate`" #: ../../builtins/stdtypes.rst:1733 msgid ":meth:`bytes.translate`" -msgstr "" +msgstr ":meth:`bytes.translate`" #: ../../builtins/stdtypes.rst:1735 msgid ":meth:`str.maketrans`" -msgstr "" +msgstr ":meth:`str.maketrans`" #: ../../builtins/stdtypes.rst:1735 msgid ":meth:`bytes.maketrans`" -msgstr "" +msgstr ":meth:`bytes.maketrans`" #: ../../builtins/stdtypes.rst:1737 msgid ":meth:`str.encode`" -msgstr "" +msgstr ":meth:`str.encode`" #: ../../builtins/stdtypes.rst:1739 msgid ":meth:`bytes.decode`" -msgstr "" +msgstr ":meth:`bytes.decode`" #: ../../builtins/stdtypes.rst:1745 msgid "Text Sequence Type --- :class:`str`" @@ -2751,6 +3083,8 @@ msgid "" ">>> str(b'Zoot!')\n" "\"b'Zoot!'\"" msgstr "" +">>> str(b'Zoot!')\n" +"\"b'Zoot!'\"" #: ../../builtins/stdtypes.rst:1827 msgid "" @@ -2762,7 +3096,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:1839 msgid "String Methods" -msgstr "" +msgstr "字串方法" #: ../../builtins/stdtypes.rst:1844 msgid "" @@ -2822,6 +3156,10 @@ msgid "" ">>> 'straße'.casefold()\n" "'strasse'" msgstr "" +">>> 'straße'.lower()\n" +"'straße'\n" +">>> 'straße'.casefold()\n" +"'strasse'" #: ../../builtins/stdtypes.rst:1887 msgid "" @@ -2846,6 +3184,12 @@ msgid "" ">>> 'Python'.center(4)\n" "'Python'" msgstr "" +">>> 'Python'.center(10)\n" +"' Python '\n" +">>> 'Python'.center(10, '-')\n" +"'--Python--'\n" +">>> 'Python'.center(4)\n" +"'Python'" #: ../../builtins/stdtypes.rst:1910 msgid "" @@ -2873,6 +3217,16 @@ msgid "" ">>> 'spam, spam, spam'.count('')\n" "17" msgstr "" +">>> 'spam, spam, spam'.count('spam')\n" +"3\n" +">>> 'spam, spam, spam'.count('spam', 5)\n" +"2\n" +">>> 'spam, spam, spam'.count('spam', 5, 10)\n" +"1\n" +">>> 'spam, spam, spam'.count('eggs')\n" +"0\n" +">>> 'spam, spam, spam'.count('')\n" +"17" #: ../../builtins/stdtypes.rst:1930 msgid "Return the string encoded to :class:`bytes`." @@ -2908,10 +3262,15 @@ msgid "" ">>> encoded_str_to_bytes\n" "b'Python'" msgstr "" +">>> encoded_str_to_bytes = 'Python'.encode()\n" +">>> type(encoded_str_to_bytes)\n" +"\n" +">>> encoded_str_to_bytes\n" +"b'Python'" #: ../../builtins/stdtypes.rst:1955 ../../builtins/stdtypes.rst:3665 msgid "Added support for keyword arguments." -msgstr "" +msgstr "新增關鍵字引數的支援。" #: ../../builtins/stdtypes.rst:1958 ../../builtins/stdtypes.rst:3668 msgid "" @@ -2939,10 +3298,18 @@ msgid "" ">>> 'Python is amazing'.endswith('is', 0, 9)\n" "True" msgstr "" +">>> 'Python'.endswith('on')\n" +"True\n" +">>> 'a tuple of suffixes'.endswith(('at', 'in'))\n" +"False\n" +">>> 'a tuple of suffixes'.endswith(('at', 'es'))\n" +"True\n" +">>> 'Python is amazing'.endswith('is', 0, 9)\n" +"True" #: ../../builtins/stdtypes.rst:1980 msgid "See also :meth:`startswith` and :meth:`removesuffix`." -msgstr "" +msgstr "另請參閱 :meth:`startswith` 和 :meth:`removesuffix`。" #: ../../builtins/stdtypes.rst:1985 msgid "" @@ -2970,6 +3337,13 @@ msgid "" "01 012\n" "0123 01234" msgstr "" +">>> '01\\t012\\t0123\\t01234'.expandtabs()\n" +"'01 012 0123 01234'\n" +">>> '01\\t012\\t0123\\t01234'.expandtabs(4)\n" +"'01 012 0123 01234'\n" +">>> print('01\\t012\\n0123\\t01234'.expandtabs(4))\n" +"01 012\n" +"0123 01234" #: ../../builtins/stdtypes.rst:2009 msgid "" @@ -2986,10 +3360,14 @@ msgid "" ">>> 'spam, spam, spam'.find('sp', 5)\n" "6" msgstr "" +">>> 'spam, spam, spam'.find('sp')\n" +"0\n" +">>> 'spam, spam, spam'.find('sp', 5)\n" +"6" #: ../../builtins/stdtypes.rst:2019 msgid "See also :meth:`rfind` and :meth:`index`." -msgstr "" +msgstr "另請參閱 :meth:`rfind` 和 :meth:`index`。" #: ../../builtins/stdtypes.rst:2023 msgid "" @@ -3003,6 +3381,8 @@ msgid "" ">>> 'Py' in 'Python'\n" "True" msgstr "" +">>> 'Py' in 'Python'\n" +"True" #: ../../builtins/stdtypes.rst:2033 msgid "" @@ -3071,10 +3451,18 @@ msgid "" " ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^\n" "ValueError: substring not found" msgstr "" +">>> 'spam, spam, spam'.index('spam')\n" +"0\n" +">>> 'spam, spam, spam'.index('eggs')\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" 'spam, spam, spam'.index('eggs')\n" +" ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^\n" +"ValueError: substring not found" #: ../../builtins/stdtypes.rst:2100 msgid "See also :meth:`rindex`." -msgstr "" +msgstr "另請參閱 :meth:`rindex`。" #: ../../builtins/stdtypes.rst:2105 msgid "" @@ -3095,6 +3483,14 @@ msgid "" ">>> ' '.isalnum()\n" "False" msgstr "" +">>> 'abc123'.isalnum()\n" +"True\n" +">>> 'abc123!@#'.isalnum()\n" +"False\n" +">>> ''.isalnum()\n" +"False\n" +">>> ' '.isalnum()\n" +"False" #: ../../builtins/stdtypes.rst:2124 msgid "" @@ -3107,6 +3503,12 @@ msgid "" "the Unicode Standard `_. For example:" msgstr "" +"如果字串中所有字元皆為字母字元且至少有一個字元,則回傳 ``True``,否則回傳 " +"``False``。字母字元是指在 Unicode 字元資料庫中被定義為「Letter」的字元,也就" +"是一般類別屬性為「Lm」、「Lt」、「Lu」、「Ll」或「Lo」其中之一的字元。請注" +"意,這與\\ `Unicode 標準第 4.10 節「Letters, Alphabetic, and Ideographic」中" +"定義的 Alphabetic 屬性 `_\\ 不同。例如:" #: ../../builtins/stdtypes.rst:2133 msgid "" @@ -3118,10 +3520,16 @@ msgid "" "too\n" "True" msgstr "" +">>> 'Letters and spaces'.isalpha()\n" +"False\n" +">>> 'LettersOnly'.isalpha()\n" +"True\n" +">>> 'µ'.isalpha() # 非 ASCII 字元也可以被視為字母\n" +"True" #: ../../builtins/stdtypes.rst:2142 msgid "See :ref:`unicode-properties`." -msgstr "" +msgstr "請參閱 :ref:`unicode-properties`。" #: ../../builtins/stdtypes.rst:2147 msgid "" @@ -3137,6 +3545,10 @@ msgid "" ">>> 'µ'.isascii()\n" "False" msgstr "" +">>> 'ASCII characters'.isascii()\n" +"True\n" +">>> 'µ'.isascii()\n" +"False" #: ../../builtins/stdtypes.rst:2163 msgid "" @@ -3156,6 +3568,12 @@ msgid "" ">>> 'alphabetic'.isdecimal()\n" "False" msgstr "" +">>> '0123456789'.isdecimal()\n" +"True\n" +">>> '٠١٢٣٤٥٦٧٨٩'.isdecimal() # 阿拉伯-印度數字零到九\n" +"True\n" +">>> 'alphabetic'.isdecimal()\n" +"False" #: ../../builtins/stdtypes.rst:2182 msgid "" @@ -3167,6 +3585,11 @@ msgid "" "Kharosthi#Numerals>`__. Formally, a digit is a character that has the " "property value Numeric_Type=Digit or Numeric_Type=Decimal." msgstr "" +"如果字串中所有字元皆為數字,且至少有一個字元,則回傳 ``True``,否則回傳 " +"``False``。數字包括十進位字元,以及需要特殊處理的數字,例如相容性上標數字。這" +"涵蓋了無法用來組成十進位數字的數字,例如\\ `佉盧文數字 `__\\ 。正式來說,數字是指具有 " +"Numeric_Type=Digit 或 Numeric_Type=Decimal 屬性值的字元。" #: ../../builtins/stdtypes.rst:2190 ../../builtins/stdtypes.rst:2271 #: ../../builtins/stdtypes.rst:2288 ../../builtins/stdtypes.rst:2315 @@ -3177,7 +3600,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:2786 ../../builtins/stdtypes.rst:2800 #: ../../builtins/stdtypes.rst:2907 msgid "For example:" -msgstr "" +msgstr "舉例來說:" #: ../../builtins/stdtypes.rst:2192 msgid "" @@ -3190,10 +3613,18 @@ msgid "" ">>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()\n" "(False, True, True)" msgstr "" +">>> '0123456789'.isdigit()\n" +"True\n" +">>> '٠١٢٣٤٥٦٧٨٩'.isdigit() # 阿拉伯-印度數字零到九\n" +"True\n" +">>> '⅕'.isdigit() # 普通分數五分之一\n" +"False\n" +">>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()\n" +"(False, True, True)" #: ../../builtins/stdtypes.rst:2203 msgid "See also :meth:`isdecimal` and :meth:`isnumeric`." -msgstr "" +msgstr "另請參閱 :meth:`isdecimal` 和 :meth:`isnumeric`。" #: ../../builtins/stdtypes.rst:2208 msgid "" @@ -3209,7 +3640,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:2214 msgid "Example: ::" -msgstr "" +msgstr "範例: ::" #: ../../builtins/stdtypes.rst:2217 msgid "" @@ -3220,9 +3651,15 @@ msgid "" ">>> 'def'.isidentifier(), iskeyword('def')\n" "(True, True)" msgstr "" - -#: ../../builtins/stdtypes.rst:2227 -msgid "" +">>> from keyword import iskeyword\n" +"\n" +">>> 'hello'.isidentifier(), iskeyword('hello')\n" +"(True, False)\n" +">>> 'def'.isidentifier(), iskeyword('def')\n" +"(True, True)" + +#: ../../builtins/stdtypes.rst:2227 +msgid "" "Return ``True`` if all cased characters [4]_ in the string are lowercase and " "there is at least one cased character, ``False`` otherwise." msgstr "" @@ -3248,10 +3685,18 @@ msgid "" ">>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()\n" "(False, True, True)" msgstr "" +">>> '0123456789'.isnumeric()\n" +"True\n" +">>> '٠١٢٣٤٥٦٧٨٩'.isnumeric() # 阿拉伯-印度數字零到九\n" +"True\n" +">>> '⅕'.isnumeric() # 普通分數五分之一\n" +"True\n" +">>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()\n" +"(False, True, True)" #: ../../builtins/stdtypes.rst:2252 msgid "See also :meth:`isdecimal` and :meth:`isdigit`." -msgstr "" +msgstr "另請參閱 :meth:`isdecimal` 和 :meth:`isdigit`。" #: ../../builtins/stdtypes.rst:2257 msgid "" @@ -3283,10 +3728,14 @@ msgid "" ">>> '\\t'.isprintable(), '\\n'.isprintable()\n" "(False, False)" msgstr "" +">>> ''.isprintable(), ' '.isprintable()\n" +"(True, True)\n" +">>> '\\t'.isprintable(), '\\n'.isprintable()\n" +"(False, False)" #: ../../builtins/stdtypes.rst:2280 msgid "See also :meth:`isspace`." -msgstr "" +msgstr "另請參閱 :meth:`isspace`。" #: ../../builtins/stdtypes.rst:2285 msgid "" @@ -3315,7 +3764,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:2306 msgid "See also :meth:`isprintable`." -msgstr "" +msgstr "另請參閱 :meth:`isprintable`。" #: ../../builtins/stdtypes.rst:2311 msgid "" @@ -3334,10 +3783,16 @@ msgid "" ">>> 'SPAM, SPAM, SPAM'.istitle()\n" "False" msgstr "" +">>> 'Spam, Spam, Spam'.istitle()\n" +"True\n" +">>> 'spam, spam, spam'.istitle()\n" +"False\n" +">>> 'SPAM, SPAM, SPAM'.istitle()\n" +"False" #: ../../builtins/stdtypes.rst:2326 msgid "See also :meth:`title`." -msgstr "" +msgstr "另請參閱 :meth:`title`。" #: ../../builtins/stdtypes.rst:2331 msgid "" @@ -3360,10 +3815,14 @@ msgid "" ">>> '-'.join('Python')\n" "'P-y-t-h-o-n'" msgstr "" +">>> ', '.join(['spam', 'spam', 'spam'])\n" +"'spam, spam, spam'\n" +">>> '-'.join('Python')\n" +"'P-y-t-h-o-n'" #: ../../builtins/stdtypes.rst:2361 msgid "See also :meth:`split`." -msgstr "" +msgstr "另請參閱 :meth:`split`。" #: ../../builtins/stdtypes.rst:2366 msgid "" @@ -3381,10 +3840,16 @@ msgid "" ">>> 'Monty Python'.ljust(10, '.')\n" "'Monty Python'" msgstr "" +">>> 'Python'.ljust(10)\n" +"'Python '\n" +">>> 'Python'.ljust(10, '.')\n" +"'Python....'\n" +">>> 'Monty Python'.ljust(10, '.')\n" +"'Monty Python'" #: ../../builtins/stdtypes.rst:2381 ../../builtins/stdtypes.rst:2916 msgid "See also :meth:`rjust`." -msgstr "" +msgstr "另請參閱 :meth:`rjust`。" #: ../../builtins/stdtypes.rst:2386 msgid "" @@ -3397,6 +3862,8 @@ msgid "" ">>> 'Lower Method Example'.lower()\n" "'lower method example'" msgstr "" +">>> 'Lower Method Example'.lower()\n" +"'lower method example'" #: ../../builtins/stdtypes.rst:2394 msgid "" @@ -3421,6 +3888,10 @@ msgid "" ">>> 'www.example.com'.lstrip('cmowz.')\n" "'example.com'" msgstr "" +">>> ' spacious '.lstrip()\n" +"'spacious '\n" +">>> 'www.example.com'.lstrip('cmowz.')\n" +"'example.com'" #: ../../builtins/stdtypes.rst:2411 msgid "" @@ -3435,6 +3906,10 @@ msgid "" ">>> 'Arthur: three!'.removeprefix('Arthur: ')\n" "'three!'" msgstr "" +">>> 'Arthur: three!'.lstrip('Arthur: ')\n" +"'ee!'\n" +">>> 'Arthur: three!'.removeprefix('Arthur: ')\n" +"'three!'" #: ../../builtins/stdtypes.rst:2423 msgid "" @@ -3475,10 +3950,16 @@ msgid "" ">>> 'Monty Python'.partition('-')\n" "('Monty Python', '', '')" msgstr "" +">>> 'Monty Python'.partition(' ')\n" +"('Monty', ' ', 'Python')\n" +">>> \"Monty Python's Flying Circus\".partition(' ')\n" +"('Monty', ' ', \"Python's Flying Circus\")\n" +">>> 'Monty Python'.partition('-')\n" +"('Monty Python', '', '')" #: ../../builtins/stdtypes.rst:2454 msgid "See also :meth:`rpartition`." -msgstr "" +msgstr "另請參閱 :meth:`rpartition`。" #: ../../builtins/stdtypes.rst:2459 msgid "" @@ -3493,10 +3974,14 @@ msgid "" ">>> 'BaseTestCase'.removeprefix('Test')\n" "'BaseTestCase'" msgstr "" +">>> 'TestHook'.removeprefix('Test')\n" +"'Hook'\n" +">>> 'BaseTestCase'.removeprefix('Test')\n" +"'BaseTestCase'" #: ../../builtins/stdtypes.rst:2472 msgid "See also :meth:`removesuffix` and :meth:`startswith`." -msgstr "" +msgstr "另請參閱 :meth:`removesuffix` 和 :meth:`startswith`。" #: ../../builtins/stdtypes.rst:2477 msgid "" @@ -3512,10 +3997,14 @@ msgid "" ">>> 'TmpDirMixin'.removesuffix('Tests')\n" "'TmpDirMixin'" msgstr "" +">>> 'MiscTests'.removesuffix('Tests')\n" +"'Misc'\n" +">>> 'TmpDirMixin'.removesuffix('Tests')\n" +"'TmpDirMixin'" #: ../../builtins/stdtypes.rst:2490 msgid "See also :meth:`removeprefix` and :meth:`endswith`." -msgstr "" +msgstr "另請參閱 :meth:`removeprefix` 和 :meth:`endswith`。" #: ../../builtins/stdtypes.rst:2495 msgid "" @@ -3532,10 +4021,14 @@ msgid "" ">>> 'spam, spam, spam'.replace('spam', 'eggs', 1)\n" "'eggs, spam, spam'" msgstr "" +">>> 'spam, spam, spam'.replace('spam', 'eggs')\n" +"'eggs, eggs, eggs'\n" +">>> 'spam, spam, spam'.replace('spam', 'eggs', 1)\n" +"'eggs, spam, spam'" #: ../../builtins/stdtypes.rst:2507 msgid "*count* is now supported as a keyword argument." -msgstr "" +msgstr "*count* 現在作為關鍵字引數被支援。" #: ../../builtins/stdtypes.rst:2513 msgid "" @@ -3552,10 +4045,14 @@ msgid "" ">>> 'spam, spam, spam'.rfind('sp', 0, 10)\n" "6" msgstr "" +">>> 'spam, spam, spam'.rfind('sp')\n" +"12\n" +">>> 'spam, spam, spam'.rfind('sp', 0, 10)\n" +"6" #: ../../builtins/stdtypes.rst:2525 msgid "See also :meth:`find` and :meth:`rindex`." -msgstr "" +msgstr "另請參閱 :meth:`find` 和 :meth:`rindex`。" #: ../../builtins/stdtypes.rst:2530 msgid "" @@ -3574,10 +4071,18 @@ msgid "" " ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^\n" "ValueError: substring not found" msgstr "" +">>> 'spam, spam, spam'.rindex('spam')\n" +"12\n" +">>> 'spam, spam, spam'.rindex('eggs')\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" 'spam, spam, spam'.rindex('eggs')\n" +" ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^\n" +"ValueError: substring not found" #: ../../builtins/stdtypes.rst:2545 msgid "See also :meth:`index` and :meth:`find`." -msgstr "" +msgstr "另請參閱 :meth:`index` 和 :meth:`find`。" #: ../../builtins/stdtypes.rst:2550 msgid "" @@ -3595,10 +4100,16 @@ msgid "" ">>> 'Monty Python'.rjust(10, '.')\n" "'Monty Python'" msgstr "" +">>> 'Python'.rjust(10)\n" +"' Python'\n" +">>> 'Python'.rjust(10, '.')\n" +"'....Python'\n" +">>> 'Monty Python'.rjust(10, '.')\n" +"'Monty Python'" #: ../../builtins/stdtypes.rst:2565 msgid "See also :meth:`ljust` and :meth:`zfill`." -msgstr "" +msgstr "另請參閱 :meth:`ljust` 和 :meth:`zfill`。" #: ../../builtins/stdtypes.rst:2570 msgid "" @@ -3617,10 +4128,16 @@ msgid "" ">>> 'Monty Python'.rpartition('-')\n" "('', '', 'Monty Python')" msgstr "" +">>> 'Monty Python'.rpartition(' ')\n" +"('Monty', ' ', 'Python')\n" +">>> \"Monty Python's Flying Circus\".rpartition(' ')\n" +"(\"Monty Python's Flying\", ' ', 'Circus')\n" +">>> 'Monty Python'.rpartition('-')\n" +"('', '', 'Monty Python')" #: ../../builtins/stdtypes.rst:2586 msgid "See also :meth:`partition`." -msgstr "" +msgstr "另請參閱 :meth:`partition`。" #: ../../builtins/stdtypes.rst:2591 msgid "" @@ -3631,6 +4148,11 @@ msgid "" "the right, :meth:`rsplit` behaves like :meth:`split` which is described in " "detail below." msgstr "" +"回傳字串中由字詞組成的 list,並以 *sep* 作為分隔字串。如果有給定 *maxsplit*," +"則最多進行 *maxsplit* 次分割,且從\\ *最右邊*\\ 開始分割。如果未指定 *sep* 或" +"其為 ``None``,則任何\\ :meth:`空白字元 `\\ 字串都會被視為分隔" +"符。除了從右邊開始分割之外,:meth:`rsplit` 的行為與下方詳述的 :meth:`split` " +"相同。" #: ../../builtins/stdtypes.rst:2601 msgid "" @@ -3648,6 +4170,10 @@ msgid "" ">>> 'mississippi'.rstrip('ipz')\n" "'mississ'" msgstr "" +">>> ' spacious '.rstrip()\n" +"' spacious'\n" +">>> 'mississippi'.rstrip('ipz')\n" +"'mississ'" #: ../../builtins/stdtypes.rst:2614 msgid "" @@ -3662,10 +4188,14 @@ msgid "" ">>> 'Monty Python'.removesuffix(' Python')\n" "'Monty'" msgstr "" +">>> 'Monty Python'.rstrip(' Python')\n" +"'M'\n" +">>> 'Monty Python'.removesuffix(' Python')\n" +"'Monty'" #: ../../builtins/stdtypes.rst:2622 msgid "See also :meth:`strip`." -msgstr "" +msgstr "另請參閱 :meth:`strip`。" #: ../../builtins/stdtypes.rst:2627 msgid "" @@ -3697,6 +4227,14 @@ msgid "" ">>> '1<>2<>3<4'.split('<>')\n" "['1', '2', '3<4']" msgstr "" +">>> '1,2,3'.split(',')\n" +"['1', '2', '3']\n" +">>> '1,2,3'.split(',', maxsplit=1)\n" +"['1', '2,3']\n" +">>> '1,2,,3,'.split(',')\n" +"['1', '2', '', '3', '']\n" +">>> '1<>2<>3<4'.split('<>')\n" +"['1', '2', '3<4']" #: ../../builtins/stdtypes.rst:2653 msgid "" @@ -3707,6 +4245,10 @@ msgid "" "Consequently, splitting an empty string or a string consisting of just " "whitespace with a ``None`` separator returns ``[]``." msgstr "" +"如果未指定 *sep* 或其為 ``None``,則會套用不同的分割演算法:連續的\\ :meth:`" +"空白字元 `\\ 會被視為單一分隔符,並且如果字串開頭或結尾有空白字" +"元,結果中不會包含空字串。因此,以 ``None`` 作為分隔符來分割空字串或僅由空白" +"字元組成的字串,會回傳 ``[]``。" #: ../../builtins/stdtypes.rst:2663 msgid "" @@ -3717,6 +4259,12 @@ msgid "" ">>> ' 1 2 3 '.split()\n" "['1', '2', '3']" msgstr "" +">>> '1 2 3'.split()\n" +"['1', '2', '3']\n" +">>> '1 2 3'.split(maxsplit=1)\n" +"['1', '2 3']\n" +">>> ' 1 2 3 '.split()\n" +"['1', '2', '3']" #: ../../builtins/stdtypes.rst:2672 msgid "" @@ -3733,10 +4281,16 @@ msgid "" ">>> \" foo \".split(maxsplit=0)\n" "['foo ']" msgstr "" +">>> \"\".split(None, 0)\n" +"[]\n" +">>> \" \".split(None, 0)\n" +"[]\n" +">>> \" foo \".split(maxsplit=0)\n" +"['foo ']" #: ../../builtins/stdtypes.rst:2686 msgid "See also :meth:`join` and :meth:`rsplit`." -msgstr "" +msgstr "另請參閱 :meth:`join` 和 :meth:`rsplit`。" #: ../../builtins/stdtypes.rst:2694 msgid "" @@ -3757,11 +4311,11 @@ msgstr "" #: ../../builtins/stdtypes.rst:2702 msgid "Description" -msgstr "" +msgstr "描述" #: ../../builtins/stdtypes.rst:2704 msgid "``\\n``" -msgstr "" +msgstr "``\\n``" #: ../../builtins/stdtypes.rst:2704 msgid "Line Feed" @@ -3769,7 +4323,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:2706 msgid "``\\r``" -msgstr "" +msgstr "``\\r``" #: ../../builtins/stdtypes.rst:2706 msgid "Carriage Return" @@ -3777,7 +4331,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:2708 msgid "``\\r\\n``" -msgstr "" +msgstr "``\\r\\n``" #: ../../builtins/stdtypes.rst:2708 msgid "Carriage Return + Line Feed" @@ -3785,7 +4339,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:2710 msgid "``\\v`` or ``\\x0b``" -msgstr "" +msgstr "``\\v`` 或 ``\\x0b``" #: ../../builtins/stdtypes.rst:2710 msgid "Line Tabulation" @@ -3793,7 +4347,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:2712 msgid "``\\f`` or ``\\x0c``" -msgstr "" +msgstr "``\\f`` 或 ``\\x0c``" #: ../../builtins/stdtypes.rst:2712 msgid "Form Feed" @@ -3801,7 +4355,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:2714 msgid "``\\x1c``" -msgstr "" +msgstr "``\\x1c``" #: ../../builtins/stdtypes.rst:2714 msgid "File Separator" @@ -3809,7 +4363,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:2716 msgid "``\\x1d``" -msgstr "" +msgstr "``\\x1d``" #: ../../builtins/stdtypes.rst:2716 msgid "Group Separator" @@ -3817,7 +4371,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:2718 msgid "``\\x1e``" -msgstr "" +msgstr "``\\x1e``" #: ../../builtins/stdtypes.rst:2718 msgid "Record Separator" @@ -3825,7 +4379,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:2720 msgid "``\\x85``" -msgstr "" +msgstr "``\\x85``" #: ../../builtins/stdtypes.rst:2720 msgid "Next Line (C1 Control Code)" @@ -3833,7 +4387,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:2722 msgid "``\\u2028``" -msgstr "" +msgstr "``\\u2028``" #: ../../builtins/stdtypes.rst:2722 msgid "Line Separator" @@ -3841,7 +4395,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:2724 msgid "``\\u2029``" -msgstr "" +msgstr "``\\u2029``" #: ../../builtins/stdtypes.rst:2724 msgid "Paragraph Separator" @@ -3861,7 +4415,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:4286 ../../builtins/stdtypes.rst:4328 #: ../../builtins/stdtypes.rst:4352 msgid "For example::" -msgstr "" +msgstr "舉例來說: ::" #: ../../builtins/stdtypes.rst:2733 msgid "" @@ -3870,6 +4424,10 @@ msgid "" ">>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" "['ab c\\n', '\\n', 'de fg\\r', 'kl\\r\\n']" msgstr "" +">>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n" +"['ab c', '', 'de fg', 'kl']\n" +">>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" +"['ab c\\n', '\\n', 'de fg\\r', 'kl\\r\\n']" #: ../../builtins/stdtypes.rst:2738 msgid "" @@ -3885,6 +4443,10 @@ msgid "" ">>> \"One line\\n\".splitlines()\n" "['One line']" msgstr "" +">>> \"\".splitlines()\n" +"[]\n" +">>> \"One line\\n\".splitlines()\n" +"['One line']" #: ../../builtins/stdtypes.rst:2747 msgid "For comparison, ``split('\\n')`` gives::" @@ -3897,6 +4459,10 @@ msgid "" ">>> 'Two lines\\n'.split('\\n')\n" "['Two lines', '']" msgstr "" +">>> ''.split('\\n')\n" +"['']\n" +">>> 'Two lines\\n'.split('\\n')\n" +"['Two lines', '']" #: ../../builtins/stdtypes.rst:2757 msgid "" @@ -3915,10 +4481,16 @@ msgid "" ">>> 'Python is amazing'.startswith('is', 7)\n" "True" msgstr "" +">>> 'Python'.startswith('Py')\n" +"True\n" +">>> 'a tuple of prefixes'.startswith(('at', 'a'))\n" +"True\n" +">>> 'Python is amazing'.startswith('is', 7)\n" +"True" #: ../../builtins/stdtypes.rst:2773 msgid "See also :meth:`endswith` and :meth:`removeprefix`." -msgstr "" +msgstr "另請參閱 :meth:`endswith` 和 :meth:`removeprefix`。" #: ../../builtins/stdtypes.rst:2778 msgid "" @@ -3940,6 +4512,10 @@ msgid "" ">>> 'www.example.com'.strip('cmowz.')\n" "'example'" msgstr "" +">>> ' spacious '.strip()\n" +"'spacious'\n" +">>> 'www.example.com'.strip('cmowz.')\n" +"'example'" #: ../../builtins/stdtypes.rst:2795 msgid "" @@ -3955,10 +4531,13 @@ msgid "" ">>> comment_string.strip('.#! ')\n" "'Section 3.2.1 Issue #32'" msgstr "" +">>> comment_string = '#....... Section 3.2.1 Issue #32 .......'\n" +">>> comment_string.strip('.#! ')\n" +"'Section 3.2.1 Issue #32'" #: ../../builtins/stdtypes.rst:2808 msgid "See also :meth:`rstrip`." -msgstr "" +msgstr "另請參閱 :meth:`rstrip`。" #: ../../builtins/stdtypes.rst:2813 msgid "" @@ -3971,6 +4550,8 @@ msgid "" ">>> 'Hello World'.swapcase()\n" "'hELLO wORLD'" msgstr "" +">>> 'Hello World'.swapcase()\n" +"'hELLO wORLD'" #: ../../builtins/stdtypes.rst:2821 msgid "" @@ -3983,10 +4564,12 @@ msgid "" ">>> 'straße'.swapcase().swapcase()\n" "'strasse'" msgstr "" +">>> 'straße'.swapcase().swapcase()\n" +"'strasse'" #: ../../builtins/stdtypes.rst:2829 msgid "See also :meth:`str.lower` and :meth:`str.upper`." -msgstr "" +msgstr "另請參閱 :meth:`str.lower` 和 :meth:`str.upper`。" #: ../../builtins/stdtypes.rst:2834 msgid "" @@ -3999,6 +4582,8 @@ msgid "" ">>> 'Hello world'.title()\n" "'Hello World'" msgstr "" +">>> 'Hello world'.title()\n" +"'Hello World'" #: ../../builtins/stdtypes.rst:2842 ../../builtins/stdtypes.rst:4296 msgid "" @@ -4013,6 +4598,8 @@ msgid "" ">>> \"they're bill's friends from the UK\".title()\n" "\"They'Re Bill'S Friends From The Uk\"" msgstr "" +">>> \"they're bill's friends from the UK\".title()\n" +"\"They'Re Bill'S Friends From The Uk\"" #: ../../builtins/stdtypes.rst:2850 msgid "" @@ -4037,10 +4624,18 @@ msgid "" ">>> titlecase(\"they're bill's friends.\")\n" "\"They're Bill's Friends.\"" msgstr "" +">>> import re\n" +">>> def titlecase(s):\n" +"... return re.sub(r\"[A-Za-z]+('[A-Za-z]+)?\",\n" +"... lambda mo: mo.group(0).capitalize(),\n" +"... s)\n" +"...\n" +">>> titlecase(\"they're bill's friends.\")\n" +"\"They're Bill's Friends.\"" #: ../../builtins/stdtypes.rst:2865 msgid "See also :meth:`istitle`." -msgstr "" +msgstr "另請參閱 :meth:`istitle`。" #: ../../builtins/stdtypes.rst:2870 msgid "" @@ -4097,6 +4692,10 @@ msgid "" ">>> \"-42\".zfill(5)\n" "'-0042'" msgstr "" +">>> \"42\".zfill(5)\n" +"'00042'\n" +">>> \"-42\".zfill(5)\n" +"'-0042'" #: ../../builtins/stdtypes.rst:2936 msgid "Formatted String Literals (f-strings)" @@ -4163,6 +4762,9 @@ msgid "" ">>> f'{number=}'\n" "'number=14.3'" msgstr "" +">>> number = 14.3\n" +">>> f'{number=}'\n" +"'number=14.3'" #: ../../builtins/stdtypes.rst:2976 msgid "" @@ -4175,6 +4777,8 @@ msgid "" ">>> f'{ number - 4 = }'\n" "' number - 4 = 10.3'" msgstr "" +">>> f'{ number - 4 = }'\n" +"' number - 4 = 10.3'" #: ../../builtins/stdtypes.rst:2984 msgid "Conversion specifier" @@ -4193,6 +4797,10 @@ msgid "" ">>> f'{one_third}'\n" "'1/3'" msgstr "" +">>> from fractions import Fraction\n" +">>> one_third = Fraction(1, 3)\n" +">>> f'{one_third}'\n" +"'1/3'" #: ../../builtins/stdtypes.rst:2994 msgid "" @@ -4205,6 +4813,8 @@ msgid "" ">>> f'{one_third = }'\n" "'one_third = Fraction(1, 3)'" msgstr "" +">>> f'{one_third = }'\n" +"'one_third = Fraction(1, 3)'" #: ../../builtins/stdtypes.rst:3000 msgid "" @@ -4213,15 +4823,15 @@ msgstr "" #: ../../builtins/stdtypes.rst:3002 msgid "``!s`` for :func:`str`" -msgstr "" +msgstr "``!s`` 用於 :func:`str`" #: ../../builtins/stdtypes.rst:3003 msgid "``!r`` for :func:`repr`" -msgstr "" +msgstr "``!r`` 用於 :func:`repr`" #: ../../builtins/stdtypes.rst:3004 msgid "``!a`` for :func:`ascii`" -msgstr "" +msgstr "``!a`` 用於 :func:`ascii`" #: ../../builtins/stdtypes.rst:3008 msgid "" @@ -4240,6 +4850,20 @@ msgid "" ">>> f'{string = !a}'\n" "\"string = '\\\\xa1ko\\\\u010dka \\\\U0001f638!'\"" msgstr "" +">>> str(one_third)\n" +"'1/3'\n" +">>> repr(one_third)\n" +"'Fraction(1, 3)'\n" +"\n" +">>> f'{one_third!s} is {one_third!r}'\n" +"'1/3 is Fraction(1, 3)'\n" +"\n" +">>> string = \"¡kočka 😸!\"\n" +">>> ascii(string)\n" +"\"'\\\\xa1ko\\\\u010dka \\\\U0001f638!'\"\n" +"\n" +">>> f'{string = !a}'\n" +"\"string = '\\\\xa1ko\\\\u010dka \\\\U0001f638!'\"" #: ../../builtins/stdtypes.rst:3025 msgid "Format specifier" @@ -4268,22 +4892,36 @@ msgid "" ">>> f'{one_third = :~>10}~'\n" "'one_third = ~~~~~~~1/3~'" msgstr "" +">>> from fractions import Fraction\n" +">>> one_third = Fraction(1, 3)\n" +">>> f'{one_third:.6f}'\n" +"'0.333333'\n" +">>> f'{one_third:_^+10}'\n" +"'___+1/3___'\n" +">>> f'{one_third!r:_^20}'\n" +"'___Fraction(1, 3)___'\n" +">>> f'{one_third = :~>10}~'\n" +"'one_third = ~~~~~~~1/3~'" #: ../../builtins/stdtypes.rst:3048 msgid "Template String Literals (t-strings)" -msgstr "" +msgstr "模板字串字面值 (t-strings)" #: ../../builtins/stdtypes.rst:3050 msgid "" "A :dfn:`t-string` (formally a :dfn:`template string literal`) is a string " "literal that is prefixed with ``t`` or ``T``." msgstr "" +":dfn:`t 字串`\\ (正式名稱為\\ :dfn:`模板字串字面值`\\ )是以 ``t`` 或 ``T`` " +"為前綴的字串字面值。" #: ../../builtins/stdtypes.rst:3053 msgid "" "These strings follow the same syntax and evaluation rules as :ref:`formatted " "string literals `, with the following differences:" msgstr "" +"這些字串遵循與\\ :ref:`格式化字串字面值 `\\ 相同的語法和求" +"值規則,但有以下差異:" #: ../../builtins/stdtypes.rst:3057 msgid "" @@ -4321,6 +4959,11 @@ msgid "" "conversion or format specifier is provided, this will override the default " "behaviour." msgstr "" +"當插值運算式中提供了等號 ``'='`` 時,該運算式的文字會被附加到相關插值前面的字" +"面字串中,這包括等號本身以及其周圍的所有空白字元。該運算式的 :class:`!" +"Interpolation` 實例會如常建立,唯一的差別是 :attr:`~string.templatelib." +"Interpolation.conversion` 預設會被設為 '``r``'(:func:`repr`)。如果有提供明" +"確的轉換方式或格式規範,則會覆蓋此預設行為。" #: ../../builtins/stdtypes.rst:3089 msgid "``printf``-style String Formatting" @@ -4356,6 +4999,8 @@ msgid "" ">>> print('%s has %d quote types.' % ('Python', 2))\n" "Python has 2 quote types." msgstr "" +">>> print('%s has %d quote types.' % ('Python', 2))\n" +"Python has 2 quote types." #: ../../builtins/stdtypes.rst:3123 msgid "" @@ -4434,7 +5079,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3180 ../../builtins/stdtypes.rst:4454 msgid "``'#'``" -msgstr "" +msgstr "``'#'``" #: ../../builtins/stdtypes.rst:3180 ../../builtins/stdtypes.rst:4454 msgid "" @@ -4443,7 +5088,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3183 ../../builtins/stdtypes.rst:4457 msgid "``'0'``" -msgstr "" +msgstr "``'0'``" #: ../../builtins/stdtypes.rst:3183 ../../builtins/stdtypes.rst:4457 msgid "The conversion will be zero padded for numeric values." @@ -4451,7 +5096,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3185 ../../builtins/stdtypes.rst:4459 msgid "``'-'``" -msgstr "" +msgstr "``'-'``" #: ../../builtins/stdtypes.rst:3185 ../../builtins/stdtypes.rst:4459 msgid "" @@ -4461,7 +5106,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3188 ../../builtins/stdtypes.rst:4462 msgid "``' '``" -msgstr "" +msgstr "``' '``" #: ../../builtins/stdtypes.rst:3188 ../../builtins/stdtypes.rst:4462 msgid "" @@ -4471,7 +5116,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3191 ../../builtins/stdtypes.rst:4465 msgid "``'+'``" -msgstr "" +msgstr "``'+'``" #: ../../builtins/stdtypes.rst:3191 ../../builtins/stdtypes.rst:4465 msgid "" @@ -4495,7 +5140,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3203 ../../builtins/stdtypes.rst:4477 msgid "``'d'``" -msgstr "" +msgstr "``'d'``" #: ../../builtins/stdtypes.rst:3203 ../../builtins/stdtypes.rst:3205 #: ../../builtins/stdtypes.rst:4477 ../../builtins/stdtypes.rst:4479 @@ -4504,11 +5149,11 @@ msgstr "" #: ../../builtins/stdtypes.rst:3205 ../../builtins/stdtypes.rst:4479 msgid "``'i'``" -msgstr "" +msgstr "``'i'``" #: ../../builtins/stdtypes.rst:3207 ../../builtins/stdtypes.rst:4481 msgid "``'o'``" -msgstr "" +msgstr "``'o'``" #: ../../builtins/stdtypes.rst:3207 ../../builtins/stdtypes.rst:4481 msgid "Signed octal value." @@ -4516,7 +5161,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3209 ../../builtins/stdtypes.rst:4483 msgid "``'u'``" -msgstr "" +msgstr "``'u'``" #: ../../builtins/stdtypes.rst:3209 ../../builtins/stdtypes.rst:4483 msgid "Obsolete type -- it is identical to ``'d'``." @@ -4524,7 +5169,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3211 ../../builtins/stdtypes.rst:4485 msgid "``'x'``" -msgstr "" +msgstr "``'x'``" #: ../../builtins/stdtypes.rst:3211 ../../builtins/stdtypes.rst:4485 msgid "Signed hexadecimal (lowercase)." @@ -4532,7 +5177,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3213 ../../builtins/stdtypes.rst:4487 msgid "``'X'``" -msgstr "" +msgstr "``'X'``" #: ../../builtins/stdtypes.rst:3213 ../../builtins/stdtypes.rst:4487 msgid "Signed hexadecimal (uppercase)." @@ -4540,7 +5185,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3215 ../../builtins/stdtypes.rst:4489 msgid "``'e'``" -msgstr "" +msgstr "``'e'``" #: ../../builtins/stdtypes.rst:3215 ../../builtins/stdtypes.rst:4489 msgid "Floating-point exponential format (lowercase)." @@ -4548,7 +5193,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3217 ../../builtins/stdtypes.rst:4491 msgid "``'E'``" -msgstr "" +msgstr "``'E'``" #: ../../builtins/stdtypes.rst:3217 ../../builtins/stdtypes.rst:4491 msgid "Floating-point exponential format (uppercase)." @@ -4556,7 +5201,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3219 ../../builtins/stdtypes.rst:4493 msgid "``'f'``" -msgstr "" +msgstr "``'f'``" #: ../../builtins/stdtypes.rst:3219 ../../builtins/stdtypes.rst:3221 #: ../../builtins/stdtypes.rst:4493 ../../builtins/stdtypes.rst:4495 @@ -4565,11 +5210,11 @@ msgstr "" #: ../../builtins/stdtypes.rst:3221 ../../builtins/stdtypes.rst:4495 msgid "``'F'``" -msgstr "" +msgstr "``'F'``" #: ../../builtins/stdtypes.rst:3223 ../../builtins/stdtypes.rst:4497 msgid "``'g'``" -msgstr "" +msgstr "``'g'``" #: ../../builtins/stdtypes.rst:3223 ../../builtins/stdtypes.rst:4497 msgid "" @@ -4579,7 +5224,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3227 ../../builtins/stdtypes.rst:4501 msgid "``'G'``" -msgstr "" +msgstr "``'G'``" #: ../../builtins/stdtypes.rst:3227 ../../builtins/stdtypes.rst:4501 msgid "" @@ -4589,7 +5234,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3231 ../../builtins/stdtypes.rst:4505 msgid "``'c'``" -msgstr "" +msgstr "``'c'``" #: ../../builtins/stdtypes.rst:3231 msgid "Single character (accepts integer or single character string)." @@ -4597,7 +5242,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3234 ../../builtins/stdtypes.rst:4518 msgid "``'r'``" -msgstr "" +msgstr "``'r'``" #: ../../builtins/stdtypes.rst:3234 msgid "String (converts any Python object using :func:`repr`)." @@ -4605,7 +5250,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3237 ../../builtins/stdtypes.rst:4512 msgid "``'s'``" -msgstr "" +msgstr "``'s'``" #: ../../builtins/stdtypes.rst:3237 msgid "String (converts any Python object using :func:`str`)." @@ -4613,7 +5258,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3240 ../../builtins/stdtypes.rst:4515 msgid "``'a'``" -msgstr "" +msgstr "``'a'``" #: ../../builtins/stdtypes.rst:3240 msgid "String (converts any Python object using :func:`ascii`)." @@ -4621,7 +5266,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3243 ../../builtins/stdtypes.rst:4521 msgid "``'%'``" -msgstr "" +msgstr "``'%'``" #: ../../builtins/stdtypes.rst:3243 ../../builtins/stdtypes.rst:4521 msgid "No argument is converted, results in a ``'%'`` character in the result." @@ -4677,7 +5322,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3279 ../../builtins/stdtypes.rst:4559 msgid "See :pep:`237`." -msgstr "" +msgstr "參閱 :pep:`237`。" #: ../../builtins/stdtypes.rst:3281 msgid "" @@ -4789,7 +5434,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3360 msgid "Also see the :ref:`bytes ` built-in." -msgstr "" +msgstr "另見內建的 :ref:`bytes `。" #: ../../builtins/stdtypes.rst:3362 msgid "" @@ -4862,7 +5507,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3429 msgid "Bytearray Objects" -msgstr "" +msgstr "Bytearray 物件" #: ../../builtins/stdtypes.rst:3433 msgid "" @@ -4878,7 +5523,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3442 msgid "Creating an empty instance: ``bytearray()``" -msgstr "" +msgstr "建立一個空的實例:``bytearray()``" #: ../../builtins/stdtypes.rst:3443 msgid "Creating a zero-filled instance with a given length: ``bytearray(10)``" @@ -4902,7 +5547,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3451 msgid "Also see the :ref:`bytearray ` built-in." -msgstr "" +msgstr "另見內建的 :ref:`bytearray `。" #: ../../builtins/stdtypes.rst:3453 msgid "" @@ -4918,6 +5563,8 @@ msgid "" "the given string object. The string must contain two hexadecimal digits per " "byte, with ASCII whitespace being ignored." msgstr "" +"這個 :class:`bytearray` 類別方法會解碼給定的字串物件,並回傳一個 bytearray 物" +"件。該字串每個位元組必須包含兩個十六進位數字,其中的 ASCII 空白字元會被忽略。" #: ../../builtins/stdtypes.rst:3466 msgid "" @@ -4963,11 +5610,11 @@ msgstr "" #: ../../builtins/stdtypes.rst:3504 msgid "This is equivalent to:" -msgstr "" +msgstr "等同於:" #: ../../builtins/stdtypes.rst:3512 msgid "Examples:" -msgstr "" +msgstr "範例:" #: ../../builtins/stdtypes.rst:3525 msgid "" @@ -4993,7 +5640,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:3544 msgid "Bytes and Bytearray Operations" -msgstr "" +msgstr "Bytes 和 Bytearray 的操作" #: ../../builtins/stdtypes.rst:3549 msgid "" @@ -5016,16 +5663,20 @@ msgid "" "a = \"abc\"\n" "b = a.replace(\"a\", \"f\")" msgstr "" +"a = \"abc\"\n" +"b = a.replace(\"a\", \"f\")" #: ../../builtins/stdtypes.rst:3564 msgid "and::" -msgstr "" +msgstr "和: ::" #: ../../builtins/stdtypes.rst:3566 msgid "" "a = b\"abc\"\n" "b = a.replace(b\"a\", b\"f\")" msgstr "" +"a = b\"abc\"\n" +"b = a.replace(b\"a\", b\"f\")" #: ../../builtins/stdtypes.rst:3569 msgid "" @@ -5087,10 +5738,14 @@ msgid "" ">>> b'BaseTestCase'.removeprefix(b'Test')\n" "b'BaseTestCase'" msgstr "" +">>> b'TestHook'.removeprefix(b'Test')\n" +"b'Hook'\n" +">>> b'BaseTestCase'.removeprefix(b'Test')\n" +"b'BaseTestCase'" #: ../../builtins/stdtypes.rst:3609 msgid "The *prefix* may be any :term:`bytes-like object`." -msgstr "" +msgstr "*prefix* 可以是任何的 :term:`bytes-like object`。" #: ../../builtins/stdtypes.rst:3613 ../../builtins/stdtypes.rst:3635 #: ../../builtins/stdtypes.rst:3768 ../../builtins/stdtypes.rst:3861 @@ -5120,6 +5775,10 @@ msgid "" ">>> b'TmpDirMixin'.removesuffix(b'Tests')\n" "b'TmpDirMixin'" msgstr "" +">>> b'MiscTests'.removesuffix(b'Tests')\n" +"b'Misc'\n" +">>> b'TmpDirMixin'.removesuffix(b'Tests')\n" +"b'TmpDirMixin'" #: ../../builtins/stdtypes.rst:3631 msgid "The *suffix* may be any :term:`bytes-like object`." @@ -5183,6 +5842,8 @@ msgid "" ">>> b'Py' in b'Python'\n" "True" msgstr "" +">>> b'Py' in b'Python'\n" +"True" #: ../../builtins/stdtypes.rst:3711 msgid "" @@ -5293,10 +5954,12 @@ msgid "" ">>> b'read this short text'.translate(None, b'aeiou')\n" "b'rd ths shrt txt'" msgstr "" +">>> b'read this short text'.translate(None, b'aeiou')\n" +"b'rd ths shrt txt'" #: ../../builtins/stdtypes.rst:3841 msgid "*delete* is now supported as a keyword argument." -msgstr "" +msgstr "支援 *delete* 關鍵字引數。" #: ../../builtins/stdtypes.rst:3845 msgid "" @@ -5331,6 +5994,10 @@ msgid "" "removing :meth:`ASCII whitespace `. The *bytes* argument is " "not a prefix; rather, all combinations of its values are stripped::" msgstr "" +"回傳一份序列的複製,並移除指定的開頭位元組。*bytes* 引數是一個二進位序列,用" +"來指定要移除的位元組值的集合。如果省略或為 ``None``,則 *bytes* 引數預設為移" +"除\\ :meth:`ASCII 空白字元 `。*bytes* 引數並非前綴;而是會移除" +"其值的所有組合出現的部分: ::" #: ../../builtins/stdtypes.rst:3889 msgid "" @@ -5339,6 +6006,10 @@ msgid "" ">>> b'www.example.com'.lstrip(b'cmowz.')\n" "b'example.com'" msgstr "" +">>> b' spacious '.lstrip()\n" +"b'spacious '\n" +">>> b'www.example.com'.lstrip(b'cmowz.')\n" +"b'example.com'" #: ../../builtins/stdtypes.rst:3894 msgid "" @@ -5354,6 +6025,10 @@ msgid "" ">>> b'Arthur: three!'.removeprefix(b'Arthur: ')\n" "b'three!'" msgstr "" +">>> b'Arthur: three!'.lstrip(b'Arthur: ')\n" +"b'ee!'\n" +">>> b'Arthur: three!'.removeprefix(b'Arthur: ')\n" +"b'three!'" #: ../../builtins/stdtypes.rst:3913 msgid "" @@ -5372,6 +6047,11 @@ msgid "" "a separator. Except for splitting from the right, :meth:`rsplit` behaves " "like :meth:`split` which is described in detail below." msgstr "" +"將二進位序列分割為多個相同型別的子序列,並以 *sep* 作為分隔字串。如果有給定 " +"*maxsplit*,則最多進行 *maxsplit* 次分割,且從\\ *最右邊*\\ 開始分割。如果未" +"指定 *sep* 或其為 ``None``,則任何完全由\\ :meth:`ASCII 空白字元 `\\ 組成的子序列都會被視為分隔符。除了從右邊開始分割之外,:meth:" +"`rsplit` 的行為與下方詳述的 :meth:`split` 相同。" #: ../../builtins/stdtypes.rst:3939 msgid "" @@ -5381,6 +6061,10 @@ msgid "" "removing :meth:`ASCII whitespace `. The *bytes* argument is " "not a suffix; rather, all combinations of its values are stripped::" msgstr "" +"回傳一份序列的複製,並移除指定的結尾位元組。*bytes* 引數是一個二進位序列,用" +"來指定要移除的位元組值的集合。如果省略或為 ``None``,則 *bytes* 引數預設為移" +"除\\ :meth:`ASCII 空白字元 `。*bytes* 引數並非後綴;而是會移除" +"其值的所有組合出現的部分: ::" #: ../../builtins/stdtypes.rst:3946 msgid "" @@ -5389,6 +6073,10 @@ msgid "" ">>> b'mississippi'.rstrip(b'ipz')\n" "b'mississ'" msgstr "" +">>> b' spacious '.rstrip()\n" +"b' spacious'\n" +">>> b'mississippi'.rstrip(b'ipz')\n" +"b'mississ'" #: ../../builtins/stdtypes.rst:3951 msgid "" @@ -5404,6 +6092,10 @@ msgid "" ">>> b'Monty Python'.removesuffix(b' Python')\n" "b'Monty'" msgstr "" +">>> b'Monty Python'.rstrip(b' Python')\n" +"b'M'\n" +">>> b'Monty Python'.removesuffix(b' Python')\n" +"b'Monty'" #: ../../builtins/stdtypes.rst:3970 msgid "" @@ -5436,6 +6128,14 @@ msgid "" ">>> b'1<>2<>3<4'.split(b'<>')\n" "[b'1', b'2', b'3<4']" msgstr "" +">>> b'1,2,3'.split(b',')\n" +"[b'1', b'2', b'3']\n" +">>> b'1,2,3'.split(b',', maxsplit=1)\n" +"[b'1', b'2,3']\n" +">>> b'1,2,,3,'.split(b',')\n" +"[b'1', b'2', b'', b'3', b'']\n" +">>> b'1<>2<>3<4'.split(b'<>')\n" +"[b'1', b'2', b'3<4']" #: ../../builtins/stdtypes.rst:3995 msgid "" @@ -5446,6 +6146,10 @@ msgid "" "Consequently, splitting an empty sequence or a sequence consisting solely of " "ASCII whitespace without a specified separator returns ``[]``." msgstr "" +"如果未指定 *sep* 或其為 ``None``,則會套用不同的分割演算法:連續的\\ :meth:" +"`ASCII 空白字元 `\\ 會被視為單一分隔符,並且如果序列開頭或結尾" +"有空白字元,結果中不會包含空字串。因此,在未指定分隔符的情況下分割空序列或僅" +"由 ASCII 空白字元組成的序列,會回傳 ``[]``。" #: ../../builtins/stdtypes.rst:4006 msgid "" @@ -5456,6 +6160,12 @@ msgid "" ">>> b' 1 2 3 '.split()\n" "[b'1', b'2', b'3']" msgstr "" +">>> b'1 2 3'.split()\n" +"[b'1', b'2', b'3']\n" +">>> b'1 2 3'.split(maxsplit=1)\n" +"[b'1', b'2 3']\n" +">>> b' 1 2 3 '.split()\n" +"[b'1', b'2', b'3']" #: ../../builtins/stdtypes.rst:4017 msgid "" @@ -5466,6 +6176,10 @@ msgid "" "argument is not a prefix or suffix; rather, all combinations of its values " "are stripped::" msgstr "" +"回傳一份序列的複製,並移除指定的開頭和結尾位元組。*bytes* 引數是一個二進位序" +"列,用來指定要移除的位元組值的集合。如果省略或為 ``None``,則 *bytes* 引數預" +"設為移除\\ :meth:`ASCII 空白字元 `。*bytes* 引數並非前綴或後" +"綴;而是會移除其值的所有組合出現的部分: ::" #: ../../builtins/stdtypes.rst:4025 msgid "" @@ -5474,6 +6188,10 @@ msgid "" ">>> b'www.example.com'.strip(b'cmowz.')\n" "b'example'" msgstr "" +">>> b' spacious '.strip()\n" +"b'spacious'\n" +">>> b'www.example.com'.strip(b'cmowz.')\n" +"b'example'" #: ../../builtins/stdtypes.rst:4030 msgid "" @@ -5519,6 +6237,10 @@ msgid "" ">>> b'01\\t012\\t0123\\t01234'.expandtabs(4)\n" "b'01 012 0123 01234'" msgstr "" +">>> b'01\\t012\\t0123\\t01234'.expandtabs()\n" +"b'01 012 0123 01234'\n" +">>> b'01\\t012\\t0123\\t01234'.expandtabs(4)\n" +"b'01 012 0123 01234'" #: ../../builtins/stdtypes.rst:4088 msgid "" @@ -5536,6 +6258,10 @@ msgid "" ">>> b'ABC abc1'.isalnum()\n" "False" msgstr "" +">>> b'ABCabc1'.isalnum()\n" +"True\n" +">>> b'ABC abc1'.isalnum()\n" +"False" #: ../../builtins/stdtypes.rst:4105 msgid "" @@ -5552,6 +6278,10 @@ msgid "" ">>> b'ABCabc1'.isalpha()\n" "False" msgstr "" +">>> b'ABCabc'.isalpha()\n" +"True\n" +">>> b'ABCabc1'.isalpha()\n" +"False" #: ../../builtins/stdtypes.rst:4121 msgid "" @@ -5573,6 +6303,10 @@ msgid "" ">>> b'1.23'.isdigit()\n" "False" msgstr "" +">>> b'1234'.isdigit()\n" +"True\n" +">>> b'1.23'.isdigit()\n" +"False" #: ../../builtins/stdtypes.rst:4146 msgid "" @@ -5587,6 +6321,10 @@ msgid "" ">>> b'Hello world'.islower()\n" "False" msgstr "" +">>> b'hello world'.islower()\n" +"True\n" +">>> b'Hello world'.islower()\n" +"False" #: ../../builtins/stdtypes.rst:4156 ../../builtins/stdtypes.rst:4198 #: ../../builtins/stdtypes.rst:4214 ../../builtins/stdtypes.rst:4264 @@ -5619,6 +6357,10 @@ msgid "" ">>> b'Hello world'.istitle()\n" "False" msgstr "" +">>> b'Hello World'.istitle()\n" +"True\n" +">>> b'Hello world'.istitle()\n" +"False" #: ../../builtins/stdtypes.rst:4188 msgid "" @@ -5634,6 +6376,10 @@ msgid "" ">>> b'Hello world'.isupper()\n" "False" msgstr "" +">>> b'HELLO WORLD'.isupper()\n" +"True\n" +">>> b'Hello world'.isupper()\n" +"False" #: ../../builtins/stdtypes.rst:4206 msgid "" @@ -5646,6 +6392,8 @@ msgid "" ">>> b'Hello World'.lower()\n" "b'hello world'" msgstr "" +">>> b'Hello World'.lower()\n" +"b'hello world'" #: ../../builtins/stdtypes.rst:4231 msgid "" @@ -5662,6 +6410,10 @@ msgid "" ">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" "[b'ab c\\n', b'\\n', b'de fg\\r', b'kl\\r\\n']" msgstr "" +">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n" +"[b'ab c', b'', b'de fg', b'kl']\n" +">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" +"[b'ab c\\n', b'\\n', b'de fg\\r', b'kl\\r\\n']" #: ../../builtins/stdtypes.rst:4243 msgid "" @@ -5677,6 +6429,10 @@ msgid "" ">>> b\"\".splitlines(), b\"One line\\n\".splitlines()\n" "([], [b'One line'])" msgstr "" +">>> b\"\".split(b'\\n'), b\"Two lines\\n\".split(b'\\n')\n" +"([b''], [b'Two lines', b''])\n" +">>> b\"\".splitlines(), b\"One line\\n\".splitlines()\n" +"([], [b'One line'])" #: ../../builtins/stdtypes.rst:4256 msgid "" @@ -5689,6 +6445,8 @@ msgid "" ">>> b'Hello World'.swapcase()\n" "b'hELLO wORLD'" msgstr "" +">>> b'Hello World'.swapcase()\n" +"b'hELLO wORLD'" #: ../../builtins/stdtypes.rst:4268 msgid "" @@ -5710,6 +6468,8 @@ msgid "" ">>> b'Hello world'.title()\n" "b'Hello World'" msgstr "" +">>> b'Hello world'.title()\n" +"b'Hello World'" #: ../../builtins/stdtypes.rst:4291 msgid "" @@ -5724,6 +6484,8 @@ msgid "" ">>> b\"they're bill's friends from the UK\".title()\n" "b\"They'Re Bill'S Friends From The Uk\"" msgstr "" +">>> b\"they're bill's friends from the UK\".title()\n" +"b\"They'Re Bill'S Friends From The Uk\"" #: ../../builtins/stdtypes.rst:4304 msgid "" @@ -5742,6 +6504,15 @@ msgid "" ">>> titlecase(b\"they're bill's friends.\")\n" "b\"They're Bill's Friends.\"" msgstr "" +">>> import re\n" +">>> def titlecase(s):\n" +"... return re.sub(rb\"[A-Za-z]+('[A-Za-z]+)?\",\n" +"... lambda mo: mo.group(0)[0:1].upper() +\n" +"... mo.group(0)[1:].lower(),\n" +"... s)\n" +"...\n" +">>> titlecase(b\"they're bill's friends.\")\n" +"b\"They're Bill's Friends.\"" #: ../../builtins/stdtypes.rst:4325 msgid "" @@ -5754,6 +6525,8 @@ msgid "" ">>> b'Hello World'.upper()\n" "b'HELLO WORLD'" msgstr "" +">>> b'Hello World'.upper()\n" +"b'HELLO WORLD'" #: ../../builtins/stdtypes.rst:4346 msgid "" @@ -5771,6 +6544,10 @@ msgid "" ">>> b\"-42\".zfill(5)\n" "b'-0042'" msgstr "" +">>> b\"42\".zfill(5)\n" +"b'00042'\n" +">>> b\"-42\".zfill(5)\n" +"b'-0042'" #: ../../builtins/stdtypes.rst:4368 msgid "``printf``-style Bytes Formatting" @@ -5793,6 +6570,11 @@ msgid "" "zero or more elements of *values*. The effect is similar to using the :c:" "func:`sprintf` function in the C language." msgstr "" +"Bytes 物件(``bytes``/``bytearray``)具有一個獨有的內建運算:``%`` 運算子(取" +"模)。這也被稱為 bytes 的\\ *格式化*\\ 或\\ *插值*\\ 運算子。給定 ``format % " +"values``\\ (其中 *format* 是一個 bytes 物件),*format* 中的 ``%`` 轉換規範" +"會被替換為零個或多個 *values* 中的元素。這樣的效果類似於在 C 語言中使用 :c:" +"func:`sprintf` 函式。" #: ../../builtins/stdtypes.rst:4397 msgid "" @@ -5812,7 +6594,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:4483 msgid "\\(8)" -msgstr "" +msgstr "\\(8)" #: ../../builtins/stdtypes.rst:4505 msgid "Single byte (accepts integer or single byte objects)." @@ -5820,7 +6602,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:4508 msgid "``'b'``" -msgstr "" +msgstr "``'b'``" #: ../../builtins/stdtypes.rst:4508 msgid "" @@ -5848,15 +6630,15 @@ msgstr "" #: ../../builtins/stdtypes.rst:4518 msgid "\\(7)" -msgstr "" +msgstr "\\(7)" #: ../../builtins/stdtypes.rst:4553 msgid "``b'%s'`` is deprecated, but will not be removed during the 3.x series." -msgstr "" +msgstr "``b'%s'`` 已被棄用,但在 3.x 系列中不會被移除。" #: ../../builtins/stdtypes.rst:4556 msgid "``b'%r'`` is deprecated, but will not be removed during the 3.x series." -msgstr "" +msgstr "``b'%r'`` 已被棄用,但在 3.x 系列中不會被移除。" #: ../../builtins/stdtypes.rst:4568 msgid ":pep:`461` - Adding % formatting to bytes and bytearray" @@ -5900,6 +6682,8 @@ msgid "" "the nested list representation of the view. If ``view.ndim == 1``, this is " "equal to the number of elements in the view." msgstr "" +"``len(view)`` 等於 :meth:`~memoryview.tolist` 的長度,也就是該檢視巢狀 list " +"表示法的長度。如果 ``view.ndim == 1``,則此值等於該檢視中元素的數量。" #: ../../builtins/stdtypes.rst:4599 msgid "" @@ -5931,6 +6715,15 @@ msgid "" ">>> bytes(v[1:4])\n" "b'bce'" msgstr "" +">>> v = memoryview(b'abcefg')\n" +">>> v[1]\n" +"98\n" +">>> v[-1]\n" +"103\n" +">>> v[1:4]\n" +"\n" +">>> bytes(v[1:4])\n" +"b'bce'" #: ../../builtins/stdtypes.rst:4618 msgid "" @@ -5959,6 +6752,15 @@ msgid "" ">>> m[::2].tolist()\n" "[-11111111, -33333333]" msgstr "" +">>> import array\n" +">>> a = array.array('l', [-11111111, 22222222, -33333333, 44444444])\n" +">>> m = memoryview(a)\n" +">>> m[0]\n" +"-11111111\n" +">>> m[-1]\n" +"44444444\n" +">>> m[::2].tolist()\n" +"[-11111111, -33333333]" #: ../../builtins/stdtypes.rst:4639 msgid "" @@ -5987,6 +6789,24 @@ msgid "" ">>> data\n" "bytearray(b'z1spam')" msgstr "" +">>> data = bytearray(b'abcefg')\n" +">>> v = memoryview(data)\n" +">>> v.readonly\n" +"False\n" +">>> v[0] = ord(b'z')\n" +">>> data\n" +"bytearray(b'zbcefg')\n" +">>> v[1:4] = b'123'\n" +">>> data\n" +"bytearray(b'z123fg')\n" +">>> v[2:3] = b'spam'\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ValueError: memoryview assignment: lvalue and rvalue have different " +"structures\n" +">>> v[2:6] = b'spam'\n" +">>> data\n" +"bytearray(b'z1spam')" #: ../../builtins/stdtypes.rst:4660 msgid "" @@ -6005,6 +6825,13 @@ msgid "" ">>> hash(v[::-2]) == hash(b'abcefg'[::-2])\n" "True" msgstr "" +">>> v = memoryview(b'abcefg')\n" +">>> hash(v) == hash(b'abcefg')\n" +"True\n" +">>> hash(v[2:4]) == hash(b'ce')\n" +"True\n" +">>> hash(v[::-2]) == hash(b'abcefg'[::-2])\n" +"True" #: ../../builtins/stdtypes.rst:4672 msgid "" @@ -6020,7 +6847,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:4680 msgid "memoryviews can now be indexed with a tuple of integers." -msgstr "" +msgstr "memoryview 現在可以用整數元組進行索引。" #: ../../builtins/stdtypes.rst:4683 msgid "memoryview is now a :term:`generic type`." @@ -6028,7 +6855,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:4686 msgid ":class:`memoryview` has several methods:" -msgstr "" +msgstr ":class:`memoryview` 有幾個方法:" #: ../../builtins/stdtypes.rst:4690 msgid "" @@ -6061,6 +6888,21 @@ msgid "" ">>> z.tolist() == c.tolist()\n" "True" msgstr "" +">>> import array\n" +">>> a = array.array('I', [1, 2, 3, 4, 5])\n" +">>> b = array.array('d', [1.0, 2.0, 3.0, 4.0, 5.0])\n" +">>> c = array.array('b', [5, 3, 1])\n" +">>> x = memoryview(a)\n" +">>> y = memoryview(b)\n" +">>> x == a == y == b\n" +"True\n" +">>> x.tolist() == a.tolist() == y.tolist() == b.tolist()\n" +"True\n" +">>> z = y[::-2]\n" +">>> z == c\n" +"True\n" +">>> z.tolist() == c.tolist()\n" +"True" #: ../../builtins/stdtypes.rst:4713 msgid "" @@ -6083,6 +6925,17 @@ msgid "" ">>> a == b\n" "False" msgstr "" +">>> from ctypes import BigEndianStructure, c_long\n" +">>> class BEPoint(BigEndianStructure):\n" +"... _fields_ = [(\"x\", c_long), (\"y\", c_long)]\n" +"...\n" +">>> point = BEPoint(100, 200)\n" +">>> a = memoryview(point)\n" +">>> b = memoryview(point)\n" +">>> a == point\n" +"False\n" +">>> a == b\n" +"False" #: ../../builtins/stdtypes.rst:4729 msgid "" @@ -6110,6 +6963,11 @@ msgid "" ">>> bytes(m)\n" "b'abc'" msgstr "" +">>> m = memoryview(b\"abc\")\n" +">>> m.tobytes()\n" +"b'abc'\n" +">>> bytes(m)\n" +"b'abc'" #: ../../builtins/stdtypes.rst:4747 msgid "" @@ -6140,6 +6998,9 @@ msgid "" ">>> m.hex()\n" "'616263'" msgstr "" +">>> m = memoryview(b\"abc\")\n" +">>> m.hex()\n" +"'616263'" #: ../../builtins/stdtypes.rst:4771 msgid "" @@ -6162,6 +7023,13 @@ msgid "" ">>> m.tolist()\n" "[1.1, 2.2, 3.3]" msgstr "" +">>> memoryview(b'abc').tolist()\n" +"[97, 98, 99]\n" +">>> import array\n" +">>> a = array.array('d', [1.1, 2.2, 3.3])\n" +">>> m = memoryview(a)\n" +">>> m.tolist()\n" +"[1.1, 2.2, 3.3]" #: ../../builtins/stdtypes.rst:4788 msgid "" @@ -6189,6 +7057,17 @@ msgid "" ">>> mm.tolist()\n" "[43, 98, 99]" msgstr "" +">>> m = memoryview(bytearray(b'abc'))\n" +">>> mm = m.toreadonly()\n" +">>> mm.tolist()\n" +"[97, 98, 99]\n" +">>> mm[0] = 42\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: cannot modify read-only memory\n" +">>> m[0] = 43\n" +">>> mm.tolist()\n" +"[43, 98, 99]" #: ../../builtins/stdtypes.rst:4814 msgid "" @@ -6215,6 +7094,12 @@ msgid "" " File \"\", line 1, in \n" "ValueError: operation forbidden on released memoryview object" msgstr "" +">>> m = memoryview(b'abc')\n" +">>> m.release()\n" +">>> m[0]\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ValueError: operation forbidden on released memoryview object" #: ../../builtins/stdtypes.rst:4831 msgid "" @@ -6233,6 +7118,14 @@ msgid "" " File \"\", line 1, in \n" "ValueError: operation forbidden on released memoryview object" msgstr "" +">>> with memoryview(b'abc') as m:\n" +"... m[0]\n" +"...\n" +"97\n" +">>> m[0]\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ValueError: operation forbidden on released memoryview object" #: ../../builtins/stdtypes.rst:4848 msgid "" @@ -6278,6 +7171,26 @@ msgid "" ">>> y.nbytes\n" "24" msgstr "" +">>> import array\n" +">>> a = array.array('l', [1,2,3])\n" +">>> x = memoryview(a)\n" +">>> x.format\n" +"'l'\n" +">>> x.itemsize\n" +"8\n" +">>> len(x)\n" +"3\n" +">>> x.nbytes\n" +"24\n" +">>> y = x.cast('B')\n" +">>> y.format\n" +"'B'\n" +">>> y.itemsize\n" +"1\n" +">>> len(y)\n" +"24\n" +">>> y.nbytes\n" +"24" #: ../../builtins/stdtypes.rst:4883 msgid "Cast 1D/unsigned bytes to 1D/char::" @@ -6296,6 +7209,16 @@ msgid "" ">>> b\n" "bytearray(b'ayz')" msgstr "" +">>> b = bytearray(b'zyz')\n" +">>> x = memoryview(b)\n" +">>> x[0] = b'a'\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: memoryview: invalid type for format 'B'\n" +">>> y = x.cast('c')\n" +">>> y[0] = b'a'\n" +">>> b\n" +"bytearray(b'ayz')" #: ../../builtins/stdtypes.rst:4896 msgid "Cast 1D/bytes to 3D/ints to 1D/signed char::" @@ -6327,6 +7250,29 @@ msgid "" ">>> z.nbytes\n" "48" msgstr "" +">>> import struct\n" +">>> buf = struct.pack(\"i\"*12, *list(range(12)))\n" +">>> x = memoryview(buf)\n" +">>> y = x.cast('i', shape=[2,2,3])\n" +">>> y.tolist()\n" +"[[[0, 1, 2], [3, 4, 5]], [[6, 7, 8], [9, 10, 11]]]\n" +">>> y.format\n" +"'i'\n" +">>> y.itemsize\n" +"4\n" +">>> len(y)\n" +"2\n" +">>> y.nbytes\n" +"48\n" +">>> z = y.cast('b')\n" +">>> z.format\n" +"'b'\n" +">>> z.itemsize\n" +"1\n" +">>> len(z)\n" +"48\n" +">>> z.nbytes\n" +"48" #: ../../builtins/stdtypes.rst:4922 msgid "Cast 1D/unsigned long to 2D/unsigned long::" @@ -6344,6 +7290,15 @@ msgid "" ">>> y.tolist()\n" "[[0, 1, 2], [3, 4, 5]]" msgstr "" +">>> buf = struct.pack(\"L\"*6, *list(range(6)))\n" +">>> x = memoryview(buf)\n" +">>> y = x.cast('L', shape=[2,3])\n" +">>> len(y)\n" +"2\n" +">>> y.nbytes\n" +"48\n" +">>> y.tolist()\n" +"[[0, 1, 2], [3, 4, 5]]" #: ../../builtins/stdtypes.rst:4936 msgid "The source format is no longer restricted when casting to a byte view." @@ -6351,7 +7306,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:4941 msgid "Count the number of occurrences of *value*." -msgstr "" +msgstr "計算 *value* 的出現次數" #: ../../builtins/stdtypes.rst:4947 msgid "" @@ -6361,7 +7316,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:4950 msgid "Raises a :exc:`ValueError` if *value* cannot be found." -msgstr "" +msgstr "在找不到 *value* 時引發 :exc:`ValueError`。" #: ../../builtins/stdtypes.rst:4954 msgid "There are also several readonly attributes available:" @@ -6369,7 +7324,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:4958 msgid "The underlying object of the memoryview::" -msgstr "" +msgstr "memoryview 的底層物件: ::" #: ../../builtins/stdtypes.rst:4960 msgid "" @@ -6378,6 +7333,10 @@ msgid "" ">>> m.obj is b\n" "True" msgstr "" +">>> b = bytearray(b'xyz')\n" +">>> m = memoryview(b)\n" +">>> m.obj is b\n" +"True" #: ../../builtins/stdtypes.rst:4969 msgid "" @@ -6403,6 +7362,20 @@ msgid "" ">>> len(y.tobytes())\n" "12" msgstr "" +">>> import array\n" +">>> a = array.array('i', [1,2,3,4,5])\n" +">>> m = memoryview(a)\n" +">>> len(m)\n" +"5\n" +">>> m.nbytes\n" +"20\n" +">>> y = m[::2]\n" +">>> len(y)\n" +"3\n" +">>> y.nbytes\n" +"12\n" +">>> len(y.tobytes())\n" +"12" #: ../../builtins/stdtypes.rst:4988 msgid "Multi-dimensional arrays::" @@ -6421,6 +7394,16 @@ msgid "" ">>> y.nbytes\n" "96" msgstr "" +">>> import struct\n" +">>> buf = struct.pack(\"d\"*12, *[1.5*x for x in range(12)])\n" +">>> x = memoryview(buf)\n" +">>> y = x.cast('d', shape=[3,4])\n" +">>> y.tolist()\n" +"[[0.0, 1.5, 3.0, 4.5], [6.0, 7.5, 9.0, 10.5], [12.0, 13.5, 15.0, 16.5]]\n" +">>> len(y)\n" +"3\n" +">>> y.nbytes\n" +"96" #: ../../builtins/stdtypes.rst:5005 msgid "A bool indicating whether the memory is read only." @@ -6455,6 +7438,14 @@ msgid "" ">>> struct.calcsize('H') == m.itemsize\n" "True" msgstr "" +">>> import array, struct\n" +">>> m = memoryview(array.array('H', [32000, 32001, 32002]))\n" +">>> m.itemsize\n" +"2\n" +">>> m[0]\n" +"32000\n" +">>> struct.calcsize('H') == m.itemsize\n" +"True" #: ../../builtins/stdtypes.rst:5033 msgid "" @@ -6514,6 +7505,11 @@ msgid "" "`collections` module.) See :ref:`time-complexity` for the costs of the " "various set operations." msgstr "" +"一個\\ :dfn:`set`\\ (集合)物件是由不重複的\\ :term:`可雜湊 `\\ 物" +"件所組成的無序集合。常見的用途包括成員測試、從序列中移除重複項目,以及計算諸" +"如交集、聯集、差集和對稱差集等數學運算。(若要了解其他容器,請參閱內建的 :" +"class:`dict`、:class:`list` 和 :class:`tuple` 類別,以及 :mod:`collections` " +"模組。)各種集合操作的成本請參閱\\ :ref:`time-complexity`\\ 。" #: ../../builtins/stdtypes.rst:5093 msgid "" @@ -6556,7 +7552,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:5122 msgid "Sets can be created by several means:" -msgstr "" +msgstr "集合可以以多種方式建立:" #: ../../builtins/stdtypes.rst:5124 msgid "" @@ -6717,7 +7713,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:5258 msgid "Add element *elem* to the set." -msgstr "" +msgstr "將元素 *elem* 加入集合。" #: ../../builtins/stdtypes.rst:5262 msgid "" @@ -6727,7 +7723,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:5267 msgid "Remove element *elem* from the set if it is present." -msgstr "" +msgstr "如果 *elem* 存在於集合中則將其移除。" #: ../../builtins/stdtypes.rst:5271 msgid "" @@ -6737,7 +7733,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:5276 msgid "Remove all elements from the set." -msgstr "" +msgstr "從集合中移除所有元素。" #: ../../builtins/stdtypes.rst:5279 msgid "" @@ -6779,6 +7775,11 @@ msgid "" "module.) See :ref:`time-complexity` for the costs of the various dictionary " "operations." msgstr "" +"一個\\ :term:`對映 `\\ 物件會將\\ :term:`可雜湊 `\\ 的值對" +"映到任意物件。對映是可變物件。目前只有一種標準的對映型別,也就是\\ :dfn:" +"`dictionary`\\ (字典)。(若要了解其他容器,請參閱內建的 :class:`list`、:" +"class:`set` 和 :class:`tuple` 類別,以及 :mod:`collections` 模組。)各種字典" +"操作的成本請參閱\\ :ref:`time-complexity`\\ 。" #: ../../builtins/stdtypes.rst:5318 msgid "" @@ -6797,7 +7798,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:5332 msgid "Dictionaries can be created by several means:" -msgstr "" +msgstr "字典可以用數種方式建立:" #: ../../builtins/stdtypes.rst:5334 msgid "" @@ -6856,6 +7857,14 @@ msgid "" ">>> a == b == c == d == e == f\n" "True" msgstr "" +">>> a = dict(one=1, two=2, three=3)\n" +">>> b = {'one': 1, 'two': 2, 'three': 3}\n" +">>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))\n" +">>> d = dict([('two', 2), ('one', 1), ('three', 3)])\n" +">>> e = dict({'three': 3, 'one': 1, 'two': 2})\n" +">>> f = dict({'one': 1, 'three': 3}, two=2)\n" +">>> a == b == c == d == e == f\n" +"True" #: ../../builtins/stdtypes.rst:5370 msgid "" @@ -6886,6 +7895,20 @@ msgid "" ">>> d\n" "{'one': 42, 'three': 3, 'four': 4, 'two': None}" msgstr "" +">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" +">>> d\n" +"{'one': 1, 'two': 2, 'three': 3, 'four': 4}\n" +">>> list(d)\n" +"['one', 'two', 'three', 'four']\n" +">>> list(d.values())\n" +"[1, 2, 3, 4]\n" +">>> d[\"one\"] = 42\n" +">>> d\n" +"{'one': 42, 'two': 2, 'three': 3, 'four': 4}\n" +">>> del d[\"two\"]\n" +">>> d[\"two\"] = None\n" +">>> d\n" +"{'one': 42, 'three': 3, 'four': 4, 'two': None}" #: ../../builtins/stdtypes.rst:5391 msgid "" @@ -6943,6 +7966,16 @@ msgid "" ">>> c['red']\n" "1" msgstr "" +">>> class Counter(dict):\n" +"... def __missing__(self, key):\n" +"... return 0\n" +"...\n" +">>> c = Counter()\n" +">>> c['red']\n" +"0\n" +">>> c['red'] += 1\n" +">>> c['red']\n" +"1" #: ../../builtins/stdtypes.rst:5435 msgid "" @@ -6953,21 +7986,21 @@ msgstr "" #: ../../builtins/stdtypes.rst:5442 msgid "Set ``d[key]`` to *value*." -msgstr "" +msgstr "將 ``d[key]`` 設為 *value*。" #: ../../builtins/stdtypes.rst:5446 msgid "" "Remove ``d[key]`` from *d*. Raises a :exc:`KeyError` if *key* is not in the " "map." -msgstr "" +msgstr "從 *d* 中移除 ``d[key]``。若 *key* 不在對映中則引發 :exc:`KeyError`。" #: ../../builtins/stdtypes.rst:5451 msgid "Return ``True`` if *d* has a key *key*, else ``False``." -msgstr "" +msgstr "若 *d* 有鍵 *key* 則回傳 ``True``,否則回傳 ``False``。" #: ../../builtins/stdtypes.rst:5455 msgid "Equivalent to ``not key in d``." -msgstr "" +msgstr "等價於 ``not key in d``。" #: ../../builtins/stdtypes.rst:5459 msgid "" @@ -6977,7 +8010,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:5464 msgid "Remove all items from the dictionary." -msgstr "" +msgstr "從字典中移除所有項目。" #: ../../builtins/stdtypes.rst:5468 msgid "Return a shallow copy of the dictionary." @@ -7088,6 +8121,9 @@ msgid "" ">>> d.values() == d.values()\n" "False" msgstr "" +">>> d = {'a': 1}\n" +">>> d.values() == d.values()\n" +"False" #: ../../builtins/stdtypes.rst:5557 msgid "" @@ -7119,6 +8155,15 @@ msgid "" ">>> list(reversed(d.items()))\n" "[('four', 4), ('three', 3), ('two', 2), ('one', 1)]" msgstr "" +">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" +">>> d\n" +"{'one': 1, 'two': 2, 'three': 3, 'four': 4}\n" +">>> list(reversed(d))\n" +"['four', 'three', 'two', 'one']\n" +">>> list(reversed(d.values()))\n" +"[4, 3, 2, 1]\n" +">>> list(reversed(d.items()))\n" +"[('four', 4), ('three', 3), ('two', 2), ('one', 1)]" #: ../../builtins/stdtypes.rst:5583 msgid "Dictionaries are now reversible." @@ -7138,7 +8183,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:5601 msgid "Dictionary view objects" -msgstr "" +msgstr "字典視圖物件" #: ../../builtins/stdtypes.rst:5603 msgid "" @@ -7265,7 +8310,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:5707 msgid "Context Manager Types" -msgstr "" +msgstr "情境管理器型別" #: ../../builtins/stdtypes.rst:5714 msgid "" @@ -7274,6 +8319,9 @@ msgid "" "that allow user-defined classes to define a runtime context that is entered " "before the statement body is executed and exited when the statement ends:" msgstr "" +"Python 的 :keyword:`with` 陳述式支援了由情境管理器定義之 runtime 情境的概念," +"要使用兩個方法來實作,該方法讓使用者定義類別能夠去定義 runtime 情境,且該情境" +"在執行陳述式主體 (statement body) 之前進入、在陳述式結束時退出:" #: ../../builtins/stdtypes.rst:5722 msgid "" @@ -7282,6 +8330,9 @@ msgid "" "to the identifier in the :keyword:`!as` clause of :keyword:`with` statements " "using this context manager." msgstr "" +"輸入 runtime 情境並回傳此物件或者與 runtime 情境相關的另一個物件。此方法回傳" +"的值有被綁定到使用此情境管理器的 :keyword:`with` 陳述式的 :keyword:`!as` 子句" +"中的識別字。" #: ../../builtins/stdtypes.rst:5727 msgid "" @@ -7289,6 +8340,8 @@ msgid "" "object`. File objects return themselves from __enter__() to allow :func:" "`open` to be used as the context expression in a :keyword:`with` statement." msgstr "" +"一個會回傳自己的情境管理器範例是 :term:`file object`。檔案物件從 __enter__() " +"回傳自己,以允許將 :func:`open` 用作 :keyword:`with` 陳述式中的情境運算式。" #: ../../builtins/stdtypes.rst:5731 msgid "" @@ -7299,6 +8352,10 @@ msgid "" "the body of the :keyword:`with` statement without affecting code outside " "the :keyword:`!with` statement." msgstr "" +"一個會回傳相關物件的情境管理器範例是由 :func:`decimal.localcontext` 回傳的管" +"理器。這些管理器將有效的十進位情境設定為原始十進位情境的副本,然後回傳該副" +"本。這允許對 :keyword:`with` 陳述式主體中的目前十進位情境進行更改,而不會影" +"響 :keyword:`!with` 陳述式外部的程式碼。" #: ../../builtins/stdtypes.rst:5741 msgid "" @@ -7308,6 +8365,9 @@ msgid "" "the exception type, value and traceback information. Otherwise, all three " "arguments are ``None``." msgstr "" +"退出 runtime 情境並回傳布林旗標以表示是否應抑制曾發生的任何例外。如果在執行 :" +"keyword:`with` 陳述式主體時發生例外,則引數包含例外型別、值和回溯 " +"(traceback) 資訊。否則,所有三個引數都是 ``None``。" #: ../../builtins/stdtypes.rst:5746 msgid "" @@ -7316,6 +8376,9 @@ msgid "" "statement immediately following the :keyword:`!with` statement. Otherwise " "the exception continues propagating after this method has finished executing." msgstr "" +"從此方法回傳 true 值將導致 :keyword:`with` 陳述式抑制例外並繼續執行緊接著 :" +"keyword:`!with` 陳述式之後的陳述式。否則,該例外將在該方法執行完畢後繼續傳播 " +"(propagate)。" #: ../../builtins/stdtypes.rst:5751 msgid "" @@ -7332,6 +8395,9 @@ msgid "" "context management code to easily detect whether or not an :meth:`~object." "__exit__` method has actually failed." msgstr "" +"傳入的例外不應明確重新引發 - 取而代之的是,此方法應回傳 false 值以指示該方法" +"已成功完成且不希望抑制引發的例外。這讓情境管理程式碼能輕鬆檢測 :meth:" +"`~object.__exit__` 方法是否曾實際失敗過。" #: ../../builtins/stdtypes.rst:5761 msgid "" @@ -7341,6 +8407,9 @@ msgid "" "are not treated specially beyond their implementation of the context " "management protocol. See the :mod:`contextlib` module for some examples." msgstr "" +"Python 定義了多個情境管理器來支援簡單的執行緒同步、檔案或其他物件的提示關閉以" +"及對有效十進位算術情境的更簡單操作。除了情境管理協定的實作之外,不會對特定型" +"別進行特殊處理。更多範例請參閱 :mod:`contextlib` 模組。" #: ../../builtins/stdtypes.rst:5767 msgid "" @@ -7351,6 +8420,11 @@ msgid "" "`~contextmanager.__enter__` and :meth:`~contextmanager.__exit__` methods, " "rather than the iterator produced by an undecorated generator function." msgstr "" +"Python 的 :term:`generator` 和 :class:`contextlib.contextmanager` 裝飾器提供" +"了一種便捷的方法來實作這些協定。如果產生器函式以 :class:`contextlib." +"contextmanager` 裝飾器裝飾,它將回傳一個有實作出需要的 :meth:" +"`~contextmanager.__enter__` 和 :meth:`~contextmanager.__exit__` 方法的情境管" +"理器,而不是由未裝飾產生器函式產生的疊代器。" #: ../../builtins/stdtypes.rst:5774 msgid "" @@ -7360,22 +8434,29 @@ msgid "" "Compared to the overhead of setting up the runtime context, the overhead of " "a single class dictionary lookup is negligible." msgstr "" +"請注意,Python/C API 中 Python 物件的型別結構中的任何方法都沒有特定的槽。想要" +"定義這些方法的擴充型別必須將它們作為普通的 Python 可存取方法提供。與設定 " +"runtime 情境的開銷相比,單一類別字典查找的開銷可以忽略不計。" #: ../../builtins/stdtypes.rst:5782 msgid "" "Type Annotation Types --- :ref:`Generic Alias `, :ref:" "`Union `" msgstr "" +"型別註釋的型別 --- :ref:`泛型別名 (Generic Alias) `、:" +"ref:`聯合 (Union) `" #: ../../builtins/stdtypes.rst:5787 msgid "" "The core built-in types for :term:`type annotations ` are :ref:" "`Generic Alias ` and :ref:`Union `." msgstr "" +":term:`型別註釋 ` 的核心內建型別是\\ :ref:`泛型別名 `\\ 和\\ :ref:`聯合 `。" #: ../../builtins/stdtypes.rst:5794 msgid "Generic Alias Type" -msgstr "" +msgstr "泛型別名型別" #: ../../builtins/stdtypes.rst:5800 msgid "" @@ -7386,18 +8467,28 @@ msgid "" "the ``list`` class with the argument :class:`int`. ``GenericAlias`` objects " "are intended primarily for use with :term:`type annotations `." msgstr "" +"``GenericAlias`` 物件通常是透過\\ :ref:`下標 (subscripting) ` " +"一個類別來建立的。它們最常與\\ :ref:`容器類別 ` 一起使用,像" +"是 :class:`list` 或 :class:`dict`。例如 ``list[int]`` 是一個 " +"``GenericAlias`` 物件,它是透過使用引數 :class:`int` 來下標 ``list`` 類別而建" +"立的。``GenericAlias`` 物件主要會與\\ :term:`型別註釋 ` 一起使" +"用。" #: ../../builtins/stdtypes.rst:5810 msgid "" "It is generally only possible to subscript a class if the class implements " "the special method :meth:`~object.__class_getitem__`." msgstr "" +"通常只有當類別有實作特殊方法 :meth:`~object.__class_getitem__` 時才可以去下標" +"該類別。" #: ../../builtins/stdtypes.rst:5813 msgid "" "A ``GenericAlias`` object acts as a proxy for a :term:`generic type`, " "implementing *parameterized generics*." msgstr "" +"將一個 ``GenericAlias`` 物件用作 :term:`generic type` 的代理,實作\\ *參數化" +"泛型 (parameterized generics)*。" #: ../../builtins/stdtypes.rst:5816 msgid "" @@ -7407,6 +8498,9 @@ msgid "" "to signify a :class:`set` in which all the elements are of type :class:" "`bytes`." msgstr "" +"對於一個容器類別,提供給該類別的\\ :ref:`下標 `\\ 引數可以代表" +"物件所包含元素的型別。例如 ``set[bytes]`` 可以用於型別註釋來表示一個 :class:" +"`set`,其中所有元素的型別都是 :class:`bytes`。" #: ../../builtins/stdtypes.rst:5822 msgid "" @@ -7416,6 +8510,9 @@ msgid "" "object. For example, :mod:`regular expressions ` can be used on both " "the :class:`str` data type and the :class:`bytes` data type:" msgstr "" +"對於定義 :meth:`~object.__class_getitem__` 但不是容器的類別,提供給該類別的下" +"標引數通常會指示物件上有定義的一個或多個方法的回傳型別。例如\\ :mod:`正規表示" +"式 `\\ 可以用於 :class:`str` 和 :class:`bytes` 資料型別:" #: ../../builtins/stdtypes.rst:5828 msgid "" @@ -7424,6 +8521,10 @@ msgid "" "both be of type :class:`str`. We can represent this kind of object in type " "annotations with the ``GenericAlias`` ``re.Match[str]``." msgstr "" +"如果 ``x = re.search('foo', 'foo')``,``x`` 將會是一個 :ref:`re.Match ` 物件,其中 ``x.group(0)`` 和 ``x[0]`` 的回傳值都是 :class:`str` 型" +"別。我們就可以用 ``GenericAlias`` ``re.Match[str]`` 在型別註釋中表示這種物" +"件。" #: ../../builtins/stdtypes.rst:5834 msgid "" @@ -7433,6 +8534,10 @@ msgid "" "annotations, we would represent this variety of :ref:`re.Match ` objects with ``re.Match[bytes]``." msgstr "" +"如果 ``y = re.search(b'bar', b'bar')``\\ (注意 :class:`bytes` 的 ``b``), " +"``y`` 也會是 ``re.Match`` 的實例,但 ``y.group(0)`` 和 ``y[0]`` 的回傳值的型" +"別都是 :class:`bytes`。在型別註釋中,我們將用 ``re.Match[bytes]`` 來表示各" +"種 :ref:`re.Match ` 物件。" #: ../../builtins/stdtypes.rst:5840 msgid "" @@ -7442,6 +8547,10 @@ msgid "" "classes>` may not be instances of :class:`types.GenericAlias`, but they " "provide similar functionality." msgstr "" +"``GenericAlias`` 物件是 :class:`types.GenericAlias` 類別的實例,也可以用來直" +"接建立 ``GenericAlias`` 物件。使用者自訂\\ :ref:`通用類別 `\\ 的特化可能不是 :class:`types.GenericAlias` 的實例,但它們提供類似" +"的功能。" #: ../../builtins/stdtypes.rst:5847 msgid "" @@ -7449,12 +8558,17 @@ msgid "" "*X*, *Y*, and more depending on the ``T`` used. For example, a function " "expecting a :class:`list` containing :class:`float` elements::" msgstr "" +"建立一個 ``GenericAlias`` 來表示一個型別 ``T``,其以型別 *X*、*Y* 等(取決於" +"所使用的 ``T``)來參數化。例如,一個函式需要一個包含 :class:`float` 元素的 :" +"class:`list`: ::" #: ../../builtins/stdtypes.rst:5852 msgid "" "def average(values: list[float]) -> float:\n" " return sum(values) / len(values)" msgstr "" +"def average(values: list[float]) -> float:\n" +" return sum(values) / len(values)" #: ../../builtins/stdtypes.rst:5855 msgid "" @@ -7463,18 +8577,25 @@ msgid "" "the value type. In this example, the function expects a ``dict`` with keys " "of type :class:`str` and values of type :class:`int`::" msgstr "" +":term:`對映 `\\ 物件的另一個範例,使用 :class:`dict`,它是一個泛型型" +"別,需要兩個型別參數,分別表示鍵型別和值型別。在此範例中,函式需要一個 " +"``dict``,其帶有 :class:`str` 型別的鍵和 :class:`int` 型別的值: ::" #: ../../builtins/stdtypes.rst:5860 msgid "" "def send_post_request(url: str, body: dict[str, int]) -> None:\n" " ..." msgstr "" +"def send_post_request(url: str, body: dict[str, int]) -> None:\n" +" ..." #: ../../builtins/stdtypes.rst:5863 msgid "" "The builtin functions :func:`isinstance` and :func:`issubclass` do not " "accept ``GenericAlias`` types for their second argument::" msgstr "" +"內建函式 :func:`isinstance` 和 :func:`issubclass` 不接受 ``GenericAlias`` 型" +"別作為第二個引數: ::" #: ../../builtins/stdtypes.rst:5866 msgid "" @@ -7483,6 +8604,10 @@ msgid "" " File \"\", line 1, in \n" "TypeError: isinstance() argument 2 cannot be a parameterized generic" msgstr "" +">>> isinstance([1, 2], list[str])\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: isinstance() argument 2 cannot be a parameterized generic" #: ../../builtins/stdtypes.rst:5871 msgid "" @@ -7492,6 +8617,9 @@ msgid "" "not checked against their type. For example, the following code is " "discouraged, but will run without errors::" msgstr "" +"Python runtime 不強制執行\\ :term:`型別註釋 `。這也擴展到泛型型別" +"及其型別參數。當從 ``GenericAlias`` 建立容器物件時,不會檢查容器中元素的型" +"別。例如,不鼓勵使用以下程式碼,但 runtime 不會出現錯誤: ::" #: ../../builtins/stdtypes.rst:5877 msgid "" @@ -7499,12 +8627,15 @@ msgid "" ">>> t([1, 2, 3])\n" "[1, 2, 3]" msgstr "" +">>> t = list[str]\n" +">>> t([1, 2, 3])\n" +"[1, 2, 3]" #: ../../builtins/stdtypes.rst:5881 msgid "" "Furthermore, parameterized generics erase type parameters during object " "creation::" -msgstr "" +msgstr "此外,參數化泛型在物件建立期間會擦除 (erase) 型別參數: ::" #: ../../builtins/stdtypes.rst:5884 msgid "" @@ -7516,12 +8647,21 @@ msgid "" ">>> type(l)\n" "" msgstr "" +">>> t = list[str]\n" +">>> type(t)\n" +"\n" +"\n" +">>> l = t()\n" +">>> type(l)\n" +"" #: ../../builtins/stdtypes.rst:5893 msgid "" "Instances of ``GenericAlias`` are not classes at runtime, even though they " "behave like classes (they can be instantiated and subclassed)::" msgstr "" +"``GenericAlias`` 的實例在執行期並不是類別,儘管它們的行為與類別相似(它們可以" +"被實例化及子類別化): ::" #: ../../builtins/stdtypes.rst:5895 msgid "" @@ -7529,17 +8669,20 @@ msgid "" ">>> inspect.isclass(list[int])\n" "False" msgstr "" +">>> import inspect\n" +">>> inspect.isclass(list[int])\n" +"False" #: ../../builtins/stdtypes.rst:5899 msgid "" "This is true for :ref:`user-defined generics ` also." -msgstr "" +msgstr "這對\\ :ref:`使用者定義泛型 `\\ 同樣適用。" #: ../../builtins/stdtypes.rst:5901 msgid "" "Calling :func:`repr` or :func:`str` on a generic shows the parameterized " "type::" -msgstr "" +msgstr "在泛型上呼叫 :func:`repr` 或 :func:`str` 會顯示參數化型別: ::" #: ../../builtins/stdtypes.rst:5903 msgid "" @@ -7549,12 +8692,19 @@ msgid "" ">>> str(list[int])\n" "'list[int]'" msgstr "" +">>> repr(list[int])\n" +"'list[int]'\n" +"\n" +">>> str(list[int])\n" +"'list[int]'" #: ../../builtins/stdtypes.rst:5909 msgid "" "The :meth:`~object.__getitem__` method of generic containers will raise an " "exception to disallow mistakes like ``dict[str][str]``::" msgstr "" +"為防止像是 ``dict[str][str]`` 的錯誤出現,泛型容器的 :meth:`~object." +"__getitem__` 方法會在這種情況下引發例外: ::" #: ../../builtins/stdtypes.rst:5912 msgid "" @@ -7563,6 +8713,10 @@ msgid "" " ...\n" "TypeError: dict[str] is not a generic class" msgstr "" +">>> dict[str][str]\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: dict[str] is not a generic class" #: ../../builtins/stdtypes.rst:5917 msgid "" @@ -7570,6 +8724,9 @@ msgid "" "are used. The index must have as many elements as there are type variable " "items in the ``GenericAlias`` object's :attr:`~genericalias.__args__`. ::" msgstr "" +"然而當使用\\ :ref:`型別變數 (type variable) ` 時,此類運算式是有效" +"的。索引的元素數量必須與 ``GenericAlias`` 物件的 :attr:`~genericalias." +"__args__` 中的型別變數項目一樣多: ::" #: ../../builtins/stdtypes.rst:5921 msgid "" @@ -7578,258 +8735,264 @@ msgid "" ">>> dict[str, Y][int]\n" "dict[str, int]" msgstr "" +">>> from typing import TypeVar\n" +">>> Y = TypeVar('Y')\n" +">>> dict[str, Y][int]\n" +"dict[str, int]" #: ../../builtins/stdtypes.rst:5928 msgid "Standard Generic Classes" -msgstr "" +msgstr "標準泛型類別" #: ../../builtins/stdtypes.rst:5930 msgid "" "The following standard library classes support parameterized generics. This " "list is non-exhaustive." -msgstr "" +msgstr "以下標準函式庫類別有支援參數化泛型。此列表並非詳盡無遺。" #: ../../builtins/stdtypes.rst:5933 msgid ":class:`tuple`" -msgstr "" +msgstr ":class:`tuple`" #: ../../builtins/stdtypes.rst:5934 msgid ":class:`list`" -msgstr "" +msgstr ":class:`list`" #: ../../builtins/stdtypes.rst:5935 msgid ":class:`dict`" -msgstr "" +msgstr ":class:`dict`" #: ../../builtins/stdtypes.rst:5936 msgid ":class:`set`" -msgstr "" +msgstr ":class:`set`" #: ../../builtins/stdtypes.rst:5937 msgid ":class:`frozenset`" -msgstr "" +msgstr ":class:`frozenset`" #: ../../builtins/stdtypes.rst:5938 msgid ":class:`type`" -msgstr "" +msgstr ":class:`type`" #: ../../builtins/stdtypes.rst:5939 msgid ":class:`asyncio.Future`" -msgstr "" +msgstr ":class:`asyncio.Future`" #: ../../builtins/stdtypes.rst:5940 msgid ":class:`asyncio.Task`" -msgstr "" +msgstr ":class:`asyncio.Task`" #: ../../builtins/stdtypes.rst:5941 msgid ":class:`collections.deque`" -msgstr "" +msgstr ":class:`collections.deque`" #: ../../builtins/stdtypes.rst:5942 msgid ":class:`collections.defaultdict`" -msgstr "" +msgstr ":class:`collections.defaultdict`" #: ../../builtins/stdtypes.rst:5943 msgid ":class:`collections.OrderedDict`" -msgstr "" +msgstr ":class:`collections.OrderedDict`" #: ../../builtins/stdtypes.rst:5944 msgid ":class:`collections.Counter`" -msgstr "" +msgstr ":class:`collections.Counter`" #: ../../builtins/stdtypes.rst:5945 msgid ":class:`collections.ChainMap`" -msgstr "" +msgstr ":class:`collections.ChainMap`" #: ../../builtins/stdtypes.rst:5946 msgid ":class:`collections.abc.Awaitable`" -msgstr "" +msgstr ":class:`collections.abc.Awaitable`" #: ../../builtins/stdtypes.rst:5947 msgid ":class:`collections.abc.Coroutine`" -msgstr "" +msgstr ":class:`collections.abc.Coroutine`" #: ../../builtins/stdtypes.rst:5948 msgid ":class:`collections.abc.AsyncIterable`" -msgstr "" +msgstr ":class:`collections.abc.AsyncIterable`" #: ../../builtins/stdtypes.rst:5949 msgid ":class:`collections.abc.AsyncIterator`" -msgstr "" +msgstr ":class:`collections.abc.AsyncIterator`" #: ../../builtins/stdtypes.rst:5950 msgid ":class:`collections.abc.AsyncGenerator`" -msgstr "" +msgstr ":class:`collections.abc.AsyncGenerator`" #: ../../builtins/stdtypes.rst:5951 msgid ":class:`collections.abc.Iterable`" -msgstr "" +msgstr ":class:`collections.abc.Iterable`" #: ../../builtins/stdtypes.rst:5952 msgid ":class:`collections.abc.Iterator`" -msgstr "" +msgstr ":class:`collections.abc.Iterator`" #: ../../builtins/stdtypes.rst:5953 msgid ":class:`collections.abc.Generator`" -msgstr "" +msgstr ":class:`collections.abc.Generator`" #: ../../builtins/stdtypes.rst:5954 msgid ":class:`collections.abc.Reversible`" -msgstr "" +msgstr ":class:`collections.abc.Reversible`" #: ../../builtins/stdtypes.rst:5955 msgid ":class:`collections.abc.Container`" -msgstr "" +msgstr ":class:`collections.abc.Container`" #: ../../builtins/stdtypes.rst:5956 msgid ":class:`collections.abc.Collection`" -msgstr "" +msgstr ":class:`collections.abc.Collection`" #: ../../builtins/stdtypes.rst:5957 msgid ":class:`collections.abc.Callable`" -msgstr "" +msgstr ":class:`collections.abc.Callable`" #: ../../builtins/stdtypes.rst:5958 msgid ":class:`collections.abc.Set`" -msgstr "" +msgstr ":class:`collections.abc.Set`" #: ../../builtins/stdtypes.rst:5959 msgid ":class:`collections.abc.MutableSet`" -msgstr "" +msgstr ":class:`collections.abc.MutableSet`" #: ../../builtins/stdtypes.rst:5960 msgid ":class:`collections.abc.Mapping`" -msgstr "" +msgstr ":class:`collections.abc.Mapping`" #: ../../builtins/stdtypes.rst:5961 msgid ":class:`collections.abc.MutableMapping`" -msgstr "" +msgstr ":class:`collections.abc.MutableMapping`" #: ../../builtins/stdtypes.rst:5962 msgid ":class:`collections.abc.Sequence`" -msgstr "" +msgstr ":class:`collections.abc.Sequence`" #: ../../builtins/stdtypes.rst:5963 msgid ":class:`collections.abc.MutableSequence`" -msgstr "" +msgstr ":class:`collections.abc.MutableSequence`" #: ../../builtins/stdtypes.rst:5964 msgid ":class:`collections.abc.ByteString`" -msgstr "" +msgstr ":class:`collections.abc.ByteString`" #: ../../builtins/stdtypes.rst:5965 msgid ":class:`collections.abc.MappingView`" -msgstr "" +msgstr ":class:`collections.abc.MappingView`" #: ../../builtins/stdtypes.rst:5966 msgid ":class:`collections.abc.KeysView`" -msgstr "" +msgstr ":class:`collections.abc.KeysView`" #: ../../builtins/stdtypes.rst:5967 msgid ":class:`collections.abc.ItemsView`" -msgstr "" +msgstr ":class:`collections.abc.ItemsView`" #: ../../builtins/stdtypes.rst:5968 msgid ":class:`collections.abc.ValuesView`" -msgstr "" +msgstr ":class:`collections.abc.ValuesView`" #: ../../builtins/stdtypes.rst:5969 msgid ":class:`contextlib.AbstractContextManager`" -msgstr "" +msgstr ":class:`contextlib.AbstractContextManager`" #: ../../builtins/stdtypes.rst:5970 msgid ":class:`contextlib.AbstractAsyncContextManager`" -msgstr "" +msgstr ":class:`contextlib.AbstractAsyncContextManager`" #: ../../builtins/stdtypes.rst:5971 msgid ":class:`dataclasses.Field`" -msgstr "" +msgstr ":class:`dataclasses.Field`" #: ../../builtins/stdtypes.rst:5972 msgid ":class:`functools.cached_property`" -msgstr "" +msgstr ":class:`functools.cached_property`" #: ../../builtins/stdtypes.rst:5973 msgid ":class:`functools.partialmethod`" -msgstr "" +msgstr ":class:`functools.partialmethod`" #: ../../builtins/stdtypes.rst:5974 msgid ":class:`os.PathLike`" -msgstr "" +msgstr ":class:`os.PathLike`" #: ../../builtins/stdtypes.rst:5975 msgid ":class:`queue.LifoQueue`" -msgstr "" +msgstr ":class:`queue.LifoQueue`" #: ../../builtins/stdtypes.rst:5976 msgid ":class:`queue.Queue`" -msgstr "" +msgstr ":class:`queue.Queue`" #: ../../builtins/stdtypes.rst:5977 msgid ":class:`queue.PriorityQueue`" -msgstr "" +msgstr ":class:`queue.PriorityQueue`" #: ../../builtins/stdtypes.rst:5978 msgid ":class:`queue.SimpleQueue`" -msgstr "" +msgstr ":class:`queue.SimpleQueue`" #: ../../builtins/stdtypes.rst:5979 msgid ":ref:`re.Pattern `" -msgstr "" +msgstr ":ref:`re.Pattern `" #: ../../builtins/stdtypes.rst:5980 msgid ":ref:`re.Match `" -msgstr "" +msgstr ":ref:`re.Match `" #: ../../builtins/stdtypes.rst:5981 msgid ":class:`shelve.BsdDbShelf`" -msgstr "" +msgstr ":class:`shelve.BsdDbShelf`" #: ../../builtins/stdtypes.rst:5982 msgid ":class:`shelve.DbfilenameShelf`" -msgstr "" +msgstr ":class:`shelve.DbfilenameShelf`" #: ../../builtins/stdtypes.rst:5983 msgid ":class:`shelve.Shelf`" -msgstr "" +msgstr ":class:`shelve.Shelf`" #: ../../builtins/stdtypes.rst:5984 msgid ":class:`types.MappingProxyType`" -msgstr "" +msgstr ":class:`types.MappingProxyType`" #: ../../builtins/stdtypes.rst:5985 msgid ":class:`weakref.WeakKeyDictionary`" -msgstr "" +msgstr ":class:`weakref.WeakKeyDictionary`" #: ../../builtins/stdtypes.rst:5986 msgid ":class:`weakref.WeakMethod`" -msgstr "" +msgstr ":class:`weakref.WeakMethod`" #: ../../builtins/stdtypes.rst:5987 msgid ":class:`weakref.WeakSet`" -msgstr "" +msgstr ":class:`weakref.WeakSet`" #: ../../builtins/stdtypes.rst:5988 msgid ":class:`weakref.WeakValueDictionary`" -msgstr "" +msgstr ":class:`weakref.WeakValueDictionary`" #: ../../builtins/stdtypes.rst:5993 msgid "Special Attributes of ``GenericAlias`` objects" -msgstr "" +msgstr "``GenericAlias`` 物件的特殊屬性" #: ../../builtins/stdtypes.rst:5995 msgid "All parameterized generics implement special read-only attributes." -msgstr "" +msgstr "所有參數化泛型都有實作特殊的唯讀屬性。" #: ../../builtins/stdtypes.rst:5999 msgid "This attribute points at the non-parameterized generic class::" -msgstr "" +msgstr "此屬性指向非參數化泛型類別: ::" #: ../../builtins/stdtypes.rst:6001 msgid "" ">>> list[int].__origin__\n" "" msgstr "" +">>> list[int].__origin__\n" +"" #: ../../builtins/stdtypes.rst:6007 msgid "" @@ -7837,18 +9000,24 @@ msgid "" "passed to the original :meth:`~object.__class_getitem__` of the generic " "class::" msgstr "" +"此屬性是傳遞給泛型類別之原始 :meth:`~object.__class_getitem__` 的泛型型別 :" +"class:`tuple`\\ (長度可以為 1): ::" #: ../../builtins/stdtypes.rst:6011 msgid "" ">>> dict[str, list[int]].__args__\n" "(, list[int])" msgstr "" +">>> dict[str, list[int]].__args__\n" +"(, list[int])" #: ../../builtins/stdtypes.rst:6017 msgid "" "This attribute is a lazily computed tuple (possibly empty) of unique type " "variables found in ``__args__``::" msgstr "" +"此屬性是個會被延遲計算 (lazily computed) 的元組(可能為空),包含了在 " +"``__args__`` 中找得到的不重複型別變數: ::" #: ../../builtins/stdtypes.rst:6020 msgid "" @@ -7858,6 +9027,11 @@ msgid "" ">>> list[T].__parameters__\n" "(~T,)" msgstr "" +">>> from typing import TypeVar\n" +"\n" +">>> T = TypeVar('T')\n" +">>> list[T].__parameters__\n" +"(~T,)" #: ../../builtins/stdtypes.rst:6028 msgid "" @@ -7865,24 +9039,29 @@ msgid "" "have correct ``__parameters__`` after substitution because :class:`typing." "ParamSpec` is intended primarily for static type checking." msgstr "" +"具有 :class:`typing.ParamSpec` 參數的一個 ``GenericAlias`` 物件在替換後可能沒" +"有正確的 ``__parameters__``,因為 :class:`typing.ParamSpec` 主要用於靜態型別" +"檢查。" #: ../../builtins/stdtypes.rst:6035 msgid "" "A boolean that is true if the alias has been unpacked using the ``*`` " "operator (see :data:`~typing.TypeVarTuple`)." msgstr "" +"如果別名已使用 ``*`` 運算子解包 (unpack) 則為 true 的布林值(請參閱 :data:" +"`~typing.TypeVarTuple`\\ )。" #: ../../builtins/stdtypes.rst:6043 msgid ":pep:`484` - Type Hints" -msgstr "" +msgstr ":pep:`484` - 型別提示" #: ../../builtins/stdtypes.rst:6044 msgid "Introducing Python's framework for type annotations." -msgstr "" +msgstr "引入 Python 的型別註釋框架。" #: ../../builtins/stdtypes.rst:6046 msgid ":pep:`585` - Type Hinting Generics In Standard Collections" -msgstr "" +msgstr ":pep:`585` - 標準集合 (Standard Collections) 中的型別提示泛型" #: ../../builtins/stdtypes.rst:6047 msgid "" @@ -7890,22 +9069,27 @@ msgid "" "provided they implement the special class method :meth:`~object." "__class_getitem__`." msgstr "" +"引入原生參數化標準函式庫類別的能力,前提是它們有實作特殊的類別方法 :meth:" +"`~object.__class_getitem__`。" #: ../../builtins/stdtypes.rst:6051 msgid "" ":ref:`Generics`, :ref:`user-defined generics ` and :" "class:`typing.Generic`" msgstr "" +":ref:`Generics`、:ref:`使用者定義泛型 `\\ 和 :class:" +"`typing.Generic`" #: ../../builtins/stdtypes.rst:6052 msgid "" "Documentation on how to implement generic classes that can be parameterized " "at runtime and understood by static type-checkers." msgstr "" +"有關如何實作可以在 runtime 參數化並能被靜態型別檢查器理解的泛型類別的文件。" #: ../../builtins/stdtypes.rst:6061 msgid "Union Type" -msgstr "" +msgstr "聯合型別 (Union Type)" #: ../../builtins/stdtypes.rst:6067 msgid "" @@ -7915,6 +9099,10 @@ msgid "" "expression enables cleaner type hinting syntax compared to subscripting :" "class:`typing.Union`." msgstr "" +"一個聯合物件可以保存多個\\ :ref:`型別物件 (type object) `\\ 之 ``|``\\ (位元 or)運算的值。這些型別主要用於\\ :term:`型別註" +"釋 (type annotation) `。與下標 :data:`typing.Union` 相比,聯合型" +"別運算式可以讓型別提示語法更清晰簡潔。" #: ../../builtins/stdtypes.rst:6074 msgid "" @@ -7923,12 +9111,17 @@ msgid "" "example, the following function expects an argument of type :class:`int` or :" "class:`float`::" msgstr "" +"定義一個包含 *X*、*Y* 等型別的聯合物件。``X | Y`` 表示 X 或 Y。它相當於 " +"``typing.Union[X, Y]``。舉例來說,下列函式需要一個型別為 :class:`int` 或 :" +"class:`float` 的引數: ::" #: ../../builtins/stdtypes.rst:6079 msgid "" "def square(number: int | float) -> int | float:\n" " return number ** 2" msgstr "" +"def square(number: int | float) -> int | float:\n" +" return number ** 2" #: ../../builtins/stdtypes.rst:6084 msgid "" @@ -7938,71 +9131,80 @@ msgid "" "For unions which include forward references, present the whole expression as " "a string, e.g. ``\"int | Foo\"``." msgstr "" +"``|`` 運算子不能在 runtime 用來定義有一個以上的成員為向前參照 (forward " +"reference) 的聯合。例如 ``int | \"Foo\"``,其中 ``\"Foo\"`` 是對尚未定義的類" +"別的參照,將在 runtime 失敗。對於包含向前參照的聯合,請將整個運算式以字串呈" +"現,例如 ``\"int | Foo\"``。" #: ../../builtins/stdtypes.rst:6092 msgid "" "Union objects can be tested for equality with other union objects. Details:" -msgstr "" +msgstr "聯合物件可以與其他聯合物件一起進行相等性測試。細節如下:" #: ../../builtins/stdtypes.rst:6094 msgid "Unions of unions are flattened::" -msgstr "" +msgstr "聯合的聯合會被扁平化: ::" #: ../../builtins/stdtypes.rst:6096 msgid "(int | str) | float == int | str | float" -msgstr "" +msgstr "(int | str) | float == int | str | float" #: ../../builtins/stdtypes.rst:6098 msgid "Redundant types are removed::" -msgstr "" +msgstr "冗餘型別會被刪除: ::" #: ../../builtins/stdtypes.rst:6100 msgid "int | str | int == int | str" -msgstr "" +msgstr "int | str | int == int | str" #: ../../builtins/stdtypes.rst:6102 msgid "When comparing unions, the order is ignored::" -msgstr "" +msgstr "比較聯合時,順序會被忽略: ::" #: ../../builtins/stdtypes.rst:6104 msgid "int | str == str | int" -msgstr "" +msgstr "int | str == str | int" #: ../../builtins/stdtypes.rst:6106 msgid "It creates instances of :class:`typing.Union`::" -msgstr "" +msgstr "它會建立 :class:`typing.Union` 的實例: ::" #: ../../builtins/stdtypes.rst:6108 msgid "" "int | str == typing.Union[int, str]\n" "type(int | str) is typing.Union" msgstr "" +"int | str == typing.Union[int, str]\n" +"type(int | str) is typing.Union" #: ../../builtins/stdtypes.rst:6111 msgid "Optional types can be spelled as a union with ``None``::" -msgstr "" +msgstr "可選型別可以表示為與 ``None`` 的聯合: ::" #: ../../builtins/stdtypes.rst:6113 msgid "str | None == typing.Optional[str]" -msgstr "" +msgstr "str | None == typing.Optional[str]" #: ../../builtins/stdtypes.rst:6118 msgid "" "Calls to :func:`isinstance` and :func:`issubclass` are also supported with a " "union object::" -msgstr "" +msgstr "聯合物件也支援 :func:`isinstance` 和 :func:`issubclass` 的呼叫: ::" #: ../../builtins/stdtypes.rst:6121 msgid "" ">>> isinstance(\"\", int | str)\n" "True" msgstr "" +">>> isinstance(\"\", int | str)\n" +"True" #: ../../builtins/stdtypes.rst:6124 msgid "" "However, :ref:`parameterized generics ` in union objects " "cannot be checked::" msgstr "" +"然而聯合物件中的\\ :ref:`參數化泛型 `\\ 則無法被檢查: ::" #: ../../builtins/stdtypes.rst:6127 msgid "" @@ -8019,6 +9221,8 @@ msgid "" "The user-exposed type for the union object can be accessed from :class:" "`typing.Union` and used for :func:`isinstance` checks::" msgstr "" +"構成聯合物件的對使用者公開型別 (user-exposed type) 可以透過 :data:`typing." +"Union` 存取並用於 :func:`isinstance` 檢查: ::" #: ../../builtins/stdtypes.rst:6137 msgid "" @@ -8030,6 +9234,13 @@ msgid "" " File \"\", line 1, in \n" "TypeError: cannot create 'typing.Union' instances" msgstr "" +">>> import typing\n" +">>> isinstance(int | str, typing.Union)\n" +"True\n" +">>> typing.Union()\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: cannot create 'typing.Union' instances" #: ../../builtins/stdtypes.rst:6146 msgid "" @@ -8037,6 +9248,8 @@ msgid "" "``X | Y``. If a metaclass implements :meth:`!__or__`, the Union may " "override it:" msgstr "" +"新增了型別物件的 :meth:`!__or__` 方法來支援 ``X | Y`` 語法。如果元類別有實" +"作 :meth:`!__or__`,則 Union 可以覆寫 (override) 它: ::" #: ../../builtins/stdtypes.rst:6150 msgid "" @@ -8052,10 +9265,21 @@ msgid "" ">>> int | C\n" "int | C" msgstr "" +">>> class M(type):\n" +"... def __or__(self, other):\n" +"... return \"Hello\"\n" +"...\n" +">>> class C(metaclass=M):\n" +"... pass\n" +"...\n" +">>> C | int\n" +"'Hello'\n" +">>> int | C\n" +"int | C" #: ../../builtins/stdtypes.rst:6166 msgid ":pep:`604` -- PEP proposing the ``X | Y`` syntax and the Union type." -msgstr "" +msgstr ":pep:`604` -- PEP 提出 ``X | Y`` 語法和聯合型別。" #: ../../builtins/stdtypes.rst:6172 msgid "" @@ -8066,7 +9290,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:6179 msgid "Other Built-in Types" -msgstr "" +msgstr "其他內建型別" #: ../../builtins/stdtypes.rst:6181 msgid "" @@ -8076,7 +9300,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:6188 msgid "Modules" -msgstr "" +msgstr "模組" #: ../../builtins/stdtypes.rst:6190 msgid "" @@ -8109,15 +9333,15 @@ msgstr "" #: ../../builtins/stdtypes.rst:6213 msgid "Classes and Class Instances" -msgstr "" +msgstr "類別與類別實例" #: ../../builtins/stdtypes.rst:6215 msgid "See :ref:`objects` and :ref:`class` for these." -msgstr "" +msgstr "請見 :ref:`objects` 和 :ref:`class`。" #: ../../builtins/stdtypes.rst:6221 msgid "Functions" -msgstr "" +msgstr "函式" #: ../../builtins/stdtypes.rst:6223 msgid "" @@ -8135,11 +9359,11 @@ msgstr "" #: ../../builtins/stdtypes.rst:6230 msgid "See :ref:`function` for more information." -msgstr "" +msgstr "更多資訊請見 :ref:`function`。" #: ../../builtins/stdtypes.rst:6236 msgid "Methods" -msgstr "" +msgstr "方法" #: ../../builtins/stdtypes.rst:6240 msgid "" @@ -8148,6 +9372,9 @@ msgid "" "`~list.append` on lists) and :ref:`class instance methods `. Built-in methods are described with the types that support them." msgstr "" +"方法是使用屬性表示法呼叫的函式,有兩種類型:\\ :ref:`內建方法 `\\ (例如 list 上的 :meth:`~list.append`\\ )和\\ :ref:`類別實例方" +"法 `。內建方法會與支援它們的型別一起說明。" #: ../../builtins/stdtypes.rst:6246 msgid "" @@ -8188,14 +9415,26 @@ msgid "" ">>> c.method.whoami\n" "'my name is method'" msgstr "" +">>> class C:\n" +"... def method(self):\n" +"... pass\n" +"...\n" +">>> c = C()\n" +">>> c.method.whoami = 'my name is method' # 不得設定於方法\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"AttributeError: 'method' object has no attribute 'whoami'\n" +">>> c.method.__func__.whoami = 'my name is method'\n" +">>> c.method.whoami\n" +"'my name is method'" #: ../../builtins/stdtypes.rst:6280 msgid "See :ref:`instance-methods` for more information." -msgstr "" +msgstr "更多資訊請見 :ref:`instance-methods`。" #: ../../builtins/stdtypes.rst:6288 msgid "Code Objects" -msgstr "" +msgstr "程式碼物件" #: ../../builtins/stdtypes.rst:6294 msgid "" @@ -8213,6 +9452,8 @@ msgid "" "` ``object.__getattr__`` with arguments ``obj`` and " "``\"__code__\"``." msgstr "" +"存取 :attr:`~function.__code__` 會引發一個附帶引數 ``obj`` 與 " +"``\"__code__\"`` 的\\ :ref:`稽核事件 ` ``object.__getattr__``。" #: ../../builtins/stdtypes.rst:6308 msgid "" @@ -8222,7 +9463,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:6311 msgid "See :ref:`types` for more information." -msgstr "" +msgstr "更多資訊請見 :ref:`types`。" #: ../../builtins/stdtypes.rst:6317 msgid "Type Objects" @@ -8242,7 +9483,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:6334 msgid "The Null Object" -msgstr "" +msgstr "Null 物件" #: ../../builtins/stdtypes.rst:6336 msgid "" @@ -8253,11 +9494,11 @@ msgstr "" #: ../../builtins/stdtypes.rst:6340 msgid "It is written as ``None``." -msgstr "" +msgstr "它被寫為 ``None``。" #: ../../builtins/stdtypes.rst:6347 msgid "The Ellipsis Object" -msgstr "" +msgstr "Ellipsis 物件" #: ../../builtins/stdtypes.rst:6349 msgid "" @@ -8269,7 +9510,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:6354 msgid "It is written as ``Ellipsis`` or ``...``." -msgstr "" +msgstr "它被寫為 ``Ellipsis`` 或 ``...``。" #: ../../builtins/stdtypes.rst:6356 msgid "" @@ -8321,7 +9562,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:6381 msgid "The NotImplemented Object" -msgstr "" +msgstr "NotImplemented 物件" #: ../../builtins/stdtypes.rst:6383 msgid "" @@ -8333,11 +9574,11 @@ msgstr "" #: ../../builtins/stdtypes.rst:6388 msgid "It is written as :code:`NotImplemented`." -msgstr "" +msgstr "它被寫為 :code:`NotImplemented`。" #: ../../builtins/stdtypes.rst:6394 msgid "Internal Objects" -msgstr "" +msgstr "內部物件" #: ../../builtins/stdtypes.rst:6396 msgid "" @@ -8348,7 +9589,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:6404 msgid "Special Attributes" -msgstr "" +msgstr "特殊屬性" #: ../../builtins/stdtypes.rst:6406 msgid "" @@ -8386,7 +9627,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:6447 msgid "Integer string conversion length limitation" -msgstr "" +msgstr "整數字串轉換長度限制" #: ../../builtins/stdtypes.rst:6449 msgid "" @@ -8395,6 +9636,10 @@ msgid "" "decimal or other non-power-of-two number bases. Hexadecimal, octal, and " "binary conversions are unlimited. The limit can be configured." msgstr "" +"CPython 針對在 :class:`int` 與 :class:`str` 之間轉換時設有一個全域限制,用於" +"降低阻斷服務 (DoS) 攻擊的風險。這個限制\\* 只\\* 適用於十進位其他非 2 的冪次" +"進位的數值。十六進位、八進位,還有二進位的轉換則沒有長度限制。此限制值可以被" +"調整。" #: ../../builtins/stdtypes.rst:6454 msgid "" @@ -8469,32 +9714,41 @@ msgid "" "... '571186405732').to_bytes(53, 'big')\n" "..." msgstr "" +">>> import sys\n" +">>> assert sys.int_info.default_max_str_digits == 4300, sys.int_info\n" +">>> assert sys.int_info.str_digits_check_threshold == 640, sys.int_info\n" +">>> msg = int('578966293710682886880994035146873798396722250538762761564'\n" +"... '9252925514383915483333812743580549779436104706260696366600'\n" +"... '571186405732').to_bytes(53, 'big')\n" +"..." #: ../../builtins/stdtypes.rst:6509 msgid "Affected APIs" -msgstr "" +msgstr "受影響的 API" #: ../../builtins/stdtypes.rst:6511 msgid "" "The limitation only applies to potentially slow conversions between :class:" "`int` and :class:`str` or :class:`bytes`:" msgstr "" +"此限制僅適用於 :class:`int` 與 :class:`str` 或 :class:`bytes` 之間可能較慢的" +"轉換:" #: ../../builtins/stdtypes.rst:6514 msgid "``int(string)`` with default base 10." -msgstr "" +msgstr "``int(string)`` 以預設的 10 為底。" #: ../../builtins/stdtypes.rst:6515 msgid "``int(string, base)`` for all bases that are not a power of 2." -msgstr "" +msgstr "``int(string, base)`` 用於所有非 2 冪次方的底。" #: ../../builtins/stdtypes.rst:6516 msgid "``str(integer)``." -msgstr "" +msgstr "``str(integer)``。" #: ../../builtins/stdtypes.rst:6517 msgid "``repr(integer)``." -msgstr "" +msgstr "``repr(integer)``。" #: ../../builtins/stdtypes.rst:6518 msgid "" @@ -8508,31 +9762,31 @@ msgstr "" #: ../../builtins/stdtypes.rst:6523 msgid "``int(string, base)`` with base 2, 4, 8, 16, or 32." -msgstr "" +msgstr "``int(string, base)`` 以 2、4、8、16 或 32 為底。" #: ../../builtins/stdtypes.rst:6524 msgid ":func:`int.from_bytes` and :func:`int.to_bytes`." -msgstr "" +msgstr ":func:`int.from_bytes` 和 :func:`int.to_bytes`。" #: ../../builtins/stdtypes.rst:6525 msgid ":func:`hex`, :func:`oct`, :func:`bin`." -msgstr "" +msgstr ":func:`hex`、:func:`oct`、:func:`bin`。" #: ../../builtins/stdtypes.rst:6526 msgid ":ref:`formatspec` for hex, octal, and binary numbers." -msgstr "" +msgstr ":ref:`formatspec` 用於十六進位、八進位和二進位數字。" #: ../../builtins/stdtypes.rst:6527 msgid ":class:`str` to :class:`float`." -msgstr "" +msgstr ":class:`str` 轉換為 :class:`float`。" #: ../../builtins/stdtypes.rst:6528 msgid ":class:`str` to :class:`decimal.Decimal`." -msgstr "" +msgstr ":class:`str` 轉換為 :class:`decimal.Decimal`。" #: ../../builtins/stdtypes.rst:6531 msgid "Configuring the limit" -msgstr "" +msgstr "設定限制" #: ../../builtins/stdtypes.rst:6533 msgid "" @@ -8552,6 +9806,8 @@ msgid "" ":option:`-X int_max_str_digits <-X>`, e.g. ``python3 -X " "int_max_str_digits=640``" msgstr "" +":option:`-X int_max_str_digits <-X>`,例如 ``python3 -X " +"int_max_str_digits=640``" #: ../../builtins/stdtypes.rst:6541 msgid "" @@ -8615,7 +9871,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:6580 msgid "Recommended configuration" -msgstr "" +msgstr "建議的配置" #: ../../builtins/stdtypes.rst:6582 msgid "" @@ -8627,7 +9883,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:6587 msgid "Example::" -msgstr "" +msgstr "範例: ::" #: ../../builtins/stdtypes.rst:6589 msgid "" @@ -8641,6 +9897,15 @@ msgid "" "... elif current_limit < lower_bound:\n" "... sys.set_int_max_str_digits(lower_bound)" msgstr "" +">>> import sys\n" +">>> if hasattr(sys, \"set_int_max_str_digits\"):\n" +"... upper_bound = 68000\n" +"... lower_bound = 4004\n" +"... current_limit = sys.get_int_max_str_digits()\n" +"... if current_limit == 0 or current_limit > upper_bound:\n" +"... sys.set_int_max_str_digits(upper_bound)\n" +"... elif current_limit < lower_bound:\n" +"... sys.set_int_max_str_digits(lower_bound)" #: ../../builtins/stdtypes.rst:6599 msgid "If you need to disable it entirely, set it to ``0``." @@ -8648,7 +9913,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:6603 msgid "Footnotes" -msgstr "" +msgstr "註腳" #: ../../builtins/stdtypes.rst:6604 msgid "" @@ -8681,7 +9946,7 @@ msgstr "" #: ../../builtins/stdtypes.rst:13 msgid "built-in" -msgstr "" +msgstr "built-in(內建)" #: ../../builtins/stdtypes.rst:13 ../../builtins/stdtypes.rst:332 #: ../../builtins/stdtypes.rst:409 ../../builtins/stdtypes.rst:1005 @@ -8689,125 +9954,125 @@ msgstr "" #: ../../builtins/stdtypes.rst:1234 ../../builtins/stdtypes.rst:5302 #: ../../builtins/stdtypes.rst:6319 msgid "types" -msgstr "" +msgstr "type(型別)" #: ../../builtins/stdtypes.rst:34 ../../builtins/stdtypes.rst:1234 #: ../../builtins/stdtypes.rst:5302 msgid "statement" -msgstr "" +msgstr "statement(陳述式)" #: ../../builtins/stdtypes.rst:34 msgid "if" -msgstr "" +msgstr "if" #: ../../builtins/stdtypes.rst:34 msgid "while" -msgstr "" +msgstr "while" #: ../../builtins/stdtypes.rst:34 msgid "truth" -msgstr "" +msgstr "truth(真)" #: ../../builtins/stdtypes.rst:34 msgid "value" -msgstr "" +msgstr "value" #: ../../builtins/stdtypes.rst:34 ../../builtins/stdtypes.rst:83 #: ../../builtins/stdtypes.rst:210 ../../builtins/stdtypes.rst:869 msgid "Boolean" -msgstr "" +msgstr "Boolean(布林)" #: ../../builtins/stdtypes.rst:34 ../../builtins/stdtypes.rst:83 #: ../../builtins/stdtypes.rst:409 msgid "operations" -msgstr "" +msgstr "operations(操作)" #: ../../builtins/stdtypes.rst:34 msgid "false" -msgstr "" +msgstr "false" #: ../../builtins/stdtypes.rst:44 msgid "true" -msgstr "" +msgstr "true" #: ../../builtins/stdtypes.rst:54 msgid "None (Built-in object)" -msgstr "" +msgstr "None(內建物件)" #: ../../builtins/stdtypes.rst:54 msgid "False (Built-in object)" -msgstr "" +msgstr "False(內建物件)" #: ../../builtins/stdtypes.rst:66 ../../builtins/stdtypes.rst:100 #: ../../builtins/stdtypes.rst:125 ../../builtins/stdtypes.rst:197 #: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:409 #: ../../builtins/stdtypes.rst:1005 msgid "operator" -msgstr "" +msgstr "operator(運算子)" #: ../../builtins/stdtypes.rst:66 ../../builtins/stdtypes.rst:100 msgid "or" -msgstr "" +msgstr "or" #: ../../builtins/stdtypes.rst:66 ../../builtins/stdtypes.rst:100 msgid "and" -msgstr "" +msgstr "and" #: ../../builtins/stdtypes.rst:66 ../../builtins/stdtypes.rst:869 msgid "False" -msgstr "" +msgstr "False" #: ../../builtins/stdtypes.rst:66 ../../builtins/stdtypes.rst:869 msgid "True" -msgstr "" +msgstr "True" #: ../../builtins/stdtypes.rst:100 msgid "not" -msgstr "" +msgstr "not" #: ../../builtins/stdtypes.rst:125 msgid "chaining" -msgstr "" +msgstr "chaining(鏈結)" #: ../../builtins/stdtypes.rst:125 msgid "comparisons" -msgstr "" +msgstr "comparisons(比較)" #: ../../builtins/stdtypes.rst:125 msgid "comparison" -msgstr "" +msgstr "comparison(比較)" #: ../../builtins/stdtypes.rst:125 msgid "==" -msgstr "" +msgstr "==" #: ../../builtins/stdtypes.rst:125 msgid "< (less)" -msgstr "" +msgstr "< (小於)" #: ../../builtins/stdtypes.rst:125 msgid "<=" -msgstr "" +msgstr "<=" #: ../../builtins/stdtypes.rst:125 msgid "> (greater)" -msgstr "" +msgstr "> (大於)" #: ../../builtins/stdtypes.rst:125 msgid ">=" -msgstr "" +msgstr ">=" #: ../../builtins/stdtypes.rst:125 msgid "!=" -msgstr "" +msgstr "!=" #: ../../builtins/stdtypes.rst:125 msgid "is" -msgstr "" +msgstr "is" #: ../../builtins/stdtypes.rst:125 msgid "is not" -msgstr "" +msgstr "is not" #: ../../builtins/stdtypes.rst:165 ../../builtins/stdtypes.rst:210 #: ../../builtins/stdtypes.rst:986 ../../builtins/stdtypes.rst:1197 @@ -8820,451 +10085,451 @@ msgstr "" #: ../../builtins/stdtypes.rst:6063 ../../builtins/stdtypes.rst:6238 #: ../../builtins/stdtypes.rst:6283 msgid "object" -msgstr "" +msgstr "object(物件)" #: ../../builtins/stdtypes.rst:165 ../../builtins/stdtypes.rst:210 #: ../../builtins/stdtypes.rst:231 ../../builtins/stdtypes.rst:332 #: ../../builtins/stdtypes.rst:351 msgid "numeric" -msgstr "" +msgstr "numeric(數值)" #: ../../builtins/stdtypes.rst:165 msgid "objects" -msgstr "" +msgstr "objects(物件)" #: ../../builtins/stdtypes.rst:165 msgid "comparing" -msgstr "" +msgstr "comparing(比較)" #: ../../builtins/stdtypes.rst:175 msgid "__eq__() (instance method)" -msgstr "" +msgstr "__eq__()(實例方法)" #: ../../builtins/stdtypes.rst:175 msgid "__ne__() (instance method)" -msgstr "" +msgstr "__ne__()(實例方法)" #: ../../builtins/stdtypes.rst:175 msgid "__lt__() (instance method)" -msgstr "" +msgstr "__lt__()(實例方法)" #: ../../builtins/stdtypes.rst:175 msgid "__le__() (instance method)" -msgstr "" +msgstr "__le__()(實例方法)" #: ../../builtins/stdtypes.rst:175 msgid "__gt__() (instance method)" -msgstr "" +msgstr "__gt__()(實例方法)" #: ../../builtins/stdtypes.rst:175 msgid "__ge__() (instance method)" -msgstr "" +msgstr "__ge__()(實例方法)" #: ../../builtins/stdtypes.rst:197 ../../builtins/stdtypes.rst:1005 msgid "in" -msgstr "" +msgstr "in" #: ../../builtins/stdtypes.rst:197 ../../builtins/stdtypes.rst:1005 msgid "not in" -msgstr "" +msgstr "not in" #: ../../builtins/stdtypes.rst:210 ../../builtins/stdtypes.rst:231 #: ../../builtins/stdtypes.rst:409 msgid "integer" -msgstr "" +msgstr "integer(整數)" #: ../../builtins/stdtypes.rst:210 ../../builtins/stdtypes.rst:231 msgid "floating-point" -msgstr "" +msgstr "floating-point(浮點數)" #: ../../builtins/stdtypes.rst:210 ../../builtins/stdtypes.rst:231 msgid "complex number" -msgstr "" +msgstr "complex number(複數)" #: ../../builtins/stdtypes.rst:210 msgid "C" -msgstr "" +msgstr "C" #: ../../builtins/stdtypes.rst:210 msgid "language" -msgstr "" +msgstr "language(語言)" #: ../../builtins/stdtypes.rst:231 msgid "literals" -msgstr "" +msgstr "literals(字面值)" #: ../../builtins/stdtypes.rst:231 msgid "hexadecimal" -msgstr "" +msgstr "hexadecimal(十六進位)" #: ../../builtins/stdtypes.rst:231 msgid "octal" -msgstr "" +msgstr "octal(八進位)" #: ../../builtins/stdtypes.rst:231 msgid "binary" -msgstr "" +msgstr "binary(二進位)" #: ../../builtins/stdtypes.rst:251 msgid "arithmetic" -msgstr "" +msgstr "arithmetic(算術)" #: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:1005 #: ../../builtins/stdtypes.rst:1197 ../../builtins/stdtypes.rst:5302 #: ../../builtins/stdtypes.rst:6290 ../../builtins/stdtypes.rst:6304 #: ../../builtins/stdtypes.rst:6319 msgid "built-in function" -msgstr "" +msgstr "built-in function(內建函式)" #: ../../builtins/stdtypes.rst:251 msgid "int" -msgstr "" +msgstr "int" #: ../../builtins/stdtypes.rst:251 msgid "float" -msgstr "" +msgstr "float" #: ../../builtins/stdtypes.rst:251 msgid "complex" -msgstr "" +msgstr "complex(複數)" #: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:3171 #: ../../builtins/stdtypes.rst:4445 msgid "+ (plus)" -msgstr "" +msgstr "+ (加號)" #: ../../builtins/stdtypes.rst:251 msgid "unary operator" -msgstr "" +msgstr "unary operator(一元運算子)" #: ../../builtins/stdtypes.rst:251 msgid "binary operator" -msgstr "" +msgstr "binary operator(二元運算子)" #: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:3171 #: ../../builtins/stdtypes.rst:4445 msgid "- (minus)" -msgstr "" +msgstr "- (減號)" #: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:3128 #: ../../builtins/stdtypes.rst:4402 msgid "* (asterisk)" -msgstr "" +msgstr "* (星號)" #: ../../builtins/stdtypes.rst:251 msgid "/ (slash)" -msgstr "" +msgstr "/ (斜線)" #: ../../builtins/stdtypes.rst:251 msgid "//" -msgstr "" +msgstr "//" #: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:3091 #: ../../builtins/stdtypes.rst:4370 msgid "% (percent)" -msgstr "" +msgstr "% (百分號)" #: ../../builtins/stdtypes.rst:251 msgid "**" -msgstr "" +msgstr "**" #: ../../builtins/stdtypes.rst:332 ../../builtins/stdtypes.rst:409 #: ../../builtins/stdtypes.rst:1005 ../../builtins/stdtypes.rst:1234 #: ../../builtins/stdtypes.rst:5302 msgid "operations on" -msgstr "" +msgstr "operations on(操作於)" #: ../../builtins/stdtypes.rst:332 msgid "conjugate() (complex number method)" -msgstr "" +msgstr "conjugate()(複數方法)" #: ../../builtins/stdtypes.rst:351 ../../builtins/stdtypes.rst:1841 #: ../../builtins/stdtypes.rst:3299 ../../builtins/stdtypes.rst:6319 msgid "module" -msgstr "" +msgstr "模組" #: ../../builtins/stdtypes.rst:351 msgid "math" -msgstr "" +msgstr "math" #: ../../builtins/stdtypes.rst:351 msgid "floor() (in module math)" -msgstr "" +msgstr "floor()(於 math 模組)" #: ../../builtins/stdtypes.rst:351 msgid "ceil() (in module math)" -msgstr "" +msgstr "ceil()(於 math 模組)" #: ../../builtins/stdtypes.rst:351 msgid "trunc() (in module math)" -msgstr "" +msgstr "trunc()(於 math 模組)" #: ../../builtins/stdtypes.rst:351 msgid "conversions" -msgstr "" +msgstr "conversions(轉換)" #: ../../builtins/stdtypes.rst:409 msgid "bitwise" -msgstr "" +msgstr "bitwise(位元)" #: ../../builtins/stdtypes.rst:409 msgid "shifting" -msgstr "" +msgstr "shifting(移位)" #: ../../builtins/stdtypes.rst:409 msgid "masking" -msgstr "" +msgstr "masking(遮罩)" #: ../../builtins/stdtypes.rst:409 msgid "| (vertical bar)" -msgstr "" +msgstr "| (垂直線)" #: ../../builtins/stdtypes.rst:409 msgid "^ (caret)" -msgstr "" +msgstr "^ (插入符號)" #: ../../builtins/stdtypes.rst:409 msgid "& (ampersand)" -msgstr "" +msgstr "& (和號)" #: ../../builtins/stdtypes.rst:409 msgid "<<" -msgstr "" +msgstr "<<" #: ../../builtins/stdtypes.rst:409 msgid ">>" -msgstr "" +msgstr ">>" #: ../../builtins/stdtypes.rst:409 msgid "~ (tilde)" -msgstr "" +msgstr "~ (波浪號)" #: ../../builtins/stdtypes.rst:869 msgid "values" -msgstr "" +msgstr "values" #: ../../builtins/stdtypes.rst:899 msgid "iterator protocol" -msgstr "" +msgstr "iterator protocol(疊代器協定)" #: ../../builtins/stdtypes.rst:899 ../../builtins/stdtypes.rst:5709 msgid "protocol" -msgstr "" +msgstr "protocol(協定)" #: ../../builtins/stdtypes.rst:899 msgid "iterator" -msgstr "" +msgstr "iterator(疊代器)" #: ../../builtins/stdtypes.rst:899 ../../builtins/stdtypes.rst:986 #: ../../builtins/stdtypes.rst:1005 ../../builtins/stdtypes.rst:1197 #: ../../builtins/stdtypes.rst:1219 ../../builtins/stdtypes.rst:1234 msgid "sequence" -msgstr "" +msgstr "sequence(序列)" #: ../../builtins/stdtypes.rst:899 msgid "iteration" -msgstr "" +msgstr "iteration(疊代)" #: ../../builtins/stdtypes.rst:899 msgid "container" -msgstr "" +msgstr "container(容器)" #: ../../builtins/stdtypes.rst:899 msgid "iteration over" -msgstr "" +msgstr "iteration over(疊代於)" #: ../../builtins/stdtypes.rst:1005 ../../builtins/stdtypes.rst:5302 msgid "len" -msgstr "" +msgstr "len" #: ../../builtins/stdtypes.rst:1005 msgid "min" -msgstr "" +msgstr "min" #: ../../builtins/stdtypes.rst:1005 msgid "max" -msgstr "" +msgstr "max" #: ../../builtins/stdtypes.rst:1005 msgid "concatenation" -msgstr "" +msgstr "concatenation(串接)" #: ../../builtins/stdtypes.rst:1005 msgid "operation" -msgstr "" +msgstr "operation(操作)" #: ../../builtins/stdtypes.rst:1005 msgid "repetition" -msgstr "" +msgstr "repetition(重複)" #: ../../builtins/stdtypes.rst:1005 ../../builtins/stdtypes.rst:1234 msgid "subscript" -msgstr "" +msgstr "subscript(下標)" #: ../../builtins/stdtypes.rst:1005 ../../builtins/stdtypes.rst:1234 msgid "slice" -msgstr "" +msgstr "slice(切片)" #: ../../builtins/stdtypes.rst:1052 msgid "loop" -msgstr "" +msgstr "loop(迴圈)" #: ../../builtins/stdtypes.rst:1052 msgid "over mutable sequence" -msgstr "" +msgstr "over mutable sequence(於可變序列)" #: ../../builtins/stdtypes.rst:1052 msgid "mutable sequence" -msgstr "" +msgstr "mutable sequence(可變序列)" #: ../../builtins/stdtypes.rst:1052 msgid "loop over" -msgstr "" +msgstr "loop over(迴圈)" #: ../../builtins/stdtypes.rst:1197 msgid "immutable" -msgstr "" +msgstr "immutable(不可變)" #: ../../builtins/stdtypes.rst:1197 ../../builtins/stdtypes.rst:1470 msgid "tuple" -msgstr "" +msgstr "tuple(元組)" #: ../../builtins/stdtypes.rst:1197 msgid "hash" -msgstr "" +msgstr "hash(雜湊)" #: ../../builtins/stdtypes.rst:1219 msgid "mutable" -msgstr "" +msgstr "mutable(可變)" #: ../../builtins/stdtypes.rst:1219 ../../builtins/stdtypes.rst:1234 #: ../../builtins/stdtypes.rst:1384 msgid "list" -msgstr "" +msgstr "list(串列)" #: ../../builtins/stdtypes.rst:1219 ../../builtins/stdtypes.rst:3299 #: ../../builtins/stdtypes.rst:3431 ../../builtins/stdtypes.rst:3546 #: ../../builtins/stdtypes.rst:4370 msgid "bytearray" -msgstr "" +msgstr "bytearray(位元組陣列)" #: ../../builtins/stdtypes.rst:1234 ../../builtins/stdtypes.rst:5302 #: ../../builtins/stdtypes.rst:6063 ../../builtins/stdtypes.rst:6319 msgid "type" -msgstr "" +msgstr "type(型別)" #: ../../builtins/stdtypes.rst:1234 msgid "assignment" -msgstr "" +msgstr "assignment(賦值)" #: ../../builtins/stdtypes.rst:1234 ../../builtins/stdtypes.rst:5302 msgid "del" -msgstr "" +msgstr "del" #: ../../builtins/stdtypes.rst:1518 msgid "range" -msgstr "" +msgstr "range" #: ../../builtins/stdtypes.rst:1639 ../../builtins/stdtypes.rst:1786 #: ../../builtins/stdtypes.rst:1833 ../../builtins/stdtypes.rst:2919 #: ../../builtins/stdtypes.rst:3091 msgid "string" -msgstr "" +msgstr "string(字串)" #: ../../builtins/stdtypes.rst:1639 msgid "text sequence type" -msgstr "" +msgstr "text sequence type(文字序列型別)" #: ../../builtins/stdtypes.rst:1639 ../../builtins/stdtypes.rst:1786 #: ../../builtins/stdtypes.rst:1806 msgid "str (built-in class)" -msgstr "" +msgstr "str(內建類別)" #: ../../builtins/stdtypes.rst:1639 msgid "(see also string)" -msgstr "" +msgstr "(亦請見 string)" #: ../../builtins/stdtypes.rst:1773 msgid "io.StringIO" -msgstr "" +msgstr "io.StringIO" #: ../../builtins/stdtypes.rst:1806 ../../builtins/stdtypes.rst:3291 msgid "buffer protocol" -msgstr "" +msgstr "buffer protocol(緩衝區協定)" #: ../../builtins/stdtypes.rst:1806 ../../builtins/stdtypes.rst:3299 #: ../../builtins/stdtypes.rst:3318 ../../builtins/stdtypes.rst:3546 #: ../../builtins/stdtypes.rst:4370 msgid "bytes" -msgstr "" +msgstr "bytes(位元組)" #: ../../builtins/stdtypes.rst:1833 ../../builtins/stdtypes.rst:3546 msgid "methods" -msgstr "" +msgstr "methods(方法)" #: ../../builtins/stdtypes.rst:1841 msgid "re" -msgstr "" +msgstr "re" #: ../../builtins/stdtypes.rst:2689 ../../builtins/stdtypes.rst:4224 msgid "universal newlines" -msgstr "" +msgstr "universal newlines" #: ../../builtins/stdtypes.rst:2689 msgid "str.splitlines method" -msgstr "" +msgstr "str.splitlines 方法" #: ../../builtins/stdtypes.rst:2919 msgid "! formatted string literal" -msgstr "" +msgstr "! formatted string literals(! 格式化字串常數)" #: ../../builtins/stdtypes.rst:2919 msgid "formatted string literals" -msgstr "" +msgstr "formatted string literals(格式化字串常數)" #: ../../builtins/stdtypes.rst:2919 msgid "! f-string" -msgstr "" +msgstr "! f-string(! f 字串)" #: ../../builtins/stdtypes.rst:2919 msgid "f-strings" -msgstr "" +msgstr "f-string(f 字串)" #: ../../builtins/stdtypes.rst:2919 msgid "fstring" -msgstr "" +msgstr "fstring(f 字串)" #: ../../builtins/stdtypes.rst:2919 msgid "interpolated string literal" -msgstr "" +msgstr "interpolated string literal(插值字串常數)" #: ../../builtins/stdtypes.rst:2919 msgid "formatted literal" -msgstr "" +msgstr "formatted literal(格式化常數)" #: ../../builtins/stdtypes.rst:2919 msgid "interpolated literal" -msgstr "" +msgstr "interpolated literal(插值常數)" #: ../../builtins/stdtypes.rst:2919 msgid "{} (curly brackets)" -msgstr "" +msgstr "{} (花括號)" #: ../../builtins/stdtypes.rst:2919 msgid "in formatted string literal" -msgstr "" +msgstr "於格式化字串常數中" #: ../../builtins/stdtypes.rst:2919 msgid "! (exclamation mark)" -msgstr "" +msgstr "! (驚嘆號)" #: ../../builtins/stdtypes.rst:2919 msgid ": (colon)" -msgstr "" +msgstr ": (冒號)" #: ../../builtins/stdtypes.rst:2919 msgid "= (equals)" -msgstr "" +msgstr "= (等號)" #: ../../builtins/stdtypes.rst:2919 msgid "for help in debugging using string literals" @@ -9272,173 +10537,173 @@ msgstr "" #: ../../builtins/stdtypes.rst:3091 msgid "formatting, string (%)" -msgstr "" +msgstr "formatting(格式化)、字串 (%)" #: ../../builtins/stdtypes.rst:3091 msgid "interpolation, string (%)" -msgstr "" +msgstr "interpolation(插值)、字串 (%)" #: ../../builtins/stdtypes.rst:3091 msgid "formatting, printf" -msgstr "" +msgstr "formatting(格式化)、printf" #: ../../builtins/stdtypes.rst:3091 msgid "interpolation, printf" -msgstr "" +msgstr "interpolation(插值)、printf" #: ../../builtins/stdtypes.rst:3091 ../../builtins/stdtypes.rst:4370 msgid "printf-style formatting" -msgstr "" +msgstr "printf 風格格式化" #: ../../builtins/stdtypes.rst:3091 ../../builtins/stdtypes.rst:4370 msgid "sprintf-style formatting" -msgstr "" +msgstr "sprintf 風格格式化" #: ../../builtins/stdtypes.rst:3128 ../../builtins/stdtypes.rst:4402 msgid "() (parentheses)" -msgstr "" +msgstr "() (圓括號)" #: ../../builtins/stdtypes.rst:3128 ../../builtins/stdtypes.rst:3171 #: ../../builtins/stdtypes.rst:4402 ../../builtins/stdtypes.rst:4445 msgid "in printf-style formatting" -msgstr "" +msgstr "於 printf 風格格式化" #: ../../builtins/stdtypes.rst:3128 ../../builtins/stdtypes.rst:4402 msgid ". (dot)" -msgstr "" +msgstr ". (點)" #: ../../builtins/stdtypes.rst:3171 ../../builtins/stdtypes.rst:4445 msgid "# (hash)" -msgstr "" +msgstr "# (井字號)" #: ../../builtins/stdtypes.rst:3171 ../../builtins/stdtypes.rst:4445 msgid "space" -msgstr "" +msgstr "space(空白)" #: ../../builtins/stdtypes.rst:3291 msgid "binary sequence types" -msgstr "" +msgstr "binary sequence types(二進位序列型別)" #: ../../builtins/stdtypes.rst:3299 msgid "memoryview" -msgstr "" +msgstr "memoryview(記憶體視圖)" #: ../../builtins/stdtypes.rst:3299 msgid "array" -msgstr "" +msgstr "array(陣列)" #: ../../builtins/stdtypes.rst:4224 msgid "bytes.splitlines method" -msgstr "" +msgstr "bytes.splitlines 方法" #: ../../builtins/stdtypes.rst:4224 msgid "bytearray.splitlines method" -msgstr "" +msgstr "bytearray.splitlines 方法" #: ../../builtins/stdtypes.rst:4370 msgid "formatting" -msgstr "" +msgstr "formatting(格式化)" #: ../../builtins/stdtypes.rst:4370 msgid "bytes (%)" -msgstr "" +msgstr "bytes (%)" #: ../../builtins/stdtypes.rst:4370 msgid "bytearray (%)" -msgstr "" +msgstr "bytearray (%)" #: ../../builtins/stdtypes.rst:4370 msgid "interpolation" -msgstr "" +msgstr "interpolation(插值)" #: ../../builtins/stdtypes.rst:5083 msgid "set" -msgstr "" +msgstr "set(集合)" #: ../../builtins/stdtypes.rst:5302 msgid "mapping" -msgstr "" +msgstr "mapping(對映)" #: ../../builtins/stdtypes.rst:5302 msgid "dictionary" -msgstr "" +msgstr "dictionary(字典)" #: ../../builtins/stdtypes.rst:5414 msgid "__missing__()" -msgstr "" +msgstr "__missing__()" #: ../../builtins/stdtypes.rst:5709 msgid "context manager" -msgstr "" +msgstr "context manager(情境管理器)" #: ../../builtins/stdtypes.rst:5709 msgid "context management protocol" -msgstr "" +msgstr "context management protocol(情境管理協定)" #: ../../builtins/stdtypes.rst:5709 msgid "context management" -msgstr "" +msgstr "context management(情境管理)" #: ../../builtins/stdtypes.rst:5784 msgid "annotation" -msgstr "" +msgstr "annotation(註記)" #: ../../builtins/stdtypes.rst:5784 msgid "type annotation; type hint" -msgstr "" +msgstr "type annotation(型別註記);type hint(型別提示)" #: ../../builtins/stdtypes.rst:5796 msgid "GenericAlias" -msgstr "" +msgstr "GenericAlias(泛型別名)" #: ../../builtins/stdtypes.rst:5796 msgid "Generic" -msgstr "" +msgstr "Generic(泛型)" #: ../../builtins/stdtypes.rst:5796 msgid "Alias" -msgstr "" +msgstr "Alias(別名)" #: ../../builtins/stdtypes.rst:6063 msgid "Union" -msgstr "" +msgstr "Union(聯合)" #: ../../builtins/stdtypes.rst:6063 msgid "union" -msgstr "" +msgstr "union(聯集)" #: ../../builtins/stdtypes.rst:6238 msgid "method" -msgstr "" +msgstr "method(方法)" #: ../../builtins/stdtypes.rst:6283 msgid "code" -msgstr "" +msgstr "code(程式碼)" #: ../../builtins/stdtypes.rst:6283 msgid "code object" -msgstr "" +msgstr "code object(程式碼物件)" #: ../../builtins/stdtypes.rst:6290 msgid "compile" -msgstr "" +msgstr "compile(編譯)" #: ../../builtins/stdtypes.rst:6290 msgid "__code__ (function object attribute)" -msgstr "" +msgstr "__code__(函式物件屬性)" #: ../../builtins/stdtypes.rst:6304 msgid "exec" -msgstr "" +msgstr "exec" #: ../../builtins/stdtypes.rst:6304 msgid "eval" -msgstr "" +msgstr "eval" #: ../../builtins/stdtypes.rst:6343 msgid "..." -msgstr "" +msgstr "..." #: ../../builtins/stdtypes.rst:6343 msgid "ellipsis literal" -msgstr "" +msgstr "ellipsis literal(刪節號字面值)" diff --git a/builtins/threadsafety.po b/builtins/threadsafety.po index afb8ec598b..1800766f21 100644 --- a/builtins/threadsafety.po +++ b/builtins/threadsafety.po @@ -19,7 +19,7 @@ msgstr "" #: ../../builtins/threadsafety.rst:5 msgid "Thread Safety Guarantees" -msgstr "" +msgstr "執行緒安全保證" #: ../../builtins/threadsafety.rst:7 msgid "" @@ -37,7 +37,7 @@ msgstr "" #: ../../builtins/threadsafety.rst:19 msgid "Thread safety levels" -msgstr "" +msgstr "執行緒安全等級" #: ../../builtins/threadsafety.rst:21 msgid "" @@ -170,6 +170,9 @@ msgid "" "lst.index(item)\n" "lst.count(item)" msgstr "" +"item in lst\n" +"lst.index(item)\n" +"lst.count(item)" #: ../../builtins/threadsafety.rst:122 msgid "" @@ -477,7 +480,7 @@ msgstr "" #: ../../builtins/threadsafety.rst:350 msgid "Thread safety for set objects" -msgstr "" +msgstr "set 物件的執行緒安全" #: ../../builtins/threadsafety.rst:352 ../../builtins/threadsafety.rst:457 msgid "" @@ -639,7 +642,7 @@ msgstr "" #: ../../builtins/threadsafety.rst:455 msgid "Thread safety for bytearray objects" -msgstr "" +msgstr "bytearray 物件的執行緒安全" #: ../../builtins/threadsafety.rst:459 msgid "" @@ -754,7 +757,7 @@ msgstr "" #: ../../builtins/threadsafety.rst:556 msgid "Thread safety for memoryview objects" -msgstr "" +msgstr "memoryview 物件的執行緒安全" #: ../../builtins/threadsafety.rst:558 msgid "" diff --git a/builtins/time-complexity.po b/builtins/time-complexity.po index f2985389d6..c15cc50db2 100644 --- a/builtins/time-complexity.po +++ b/builtins/time-complexity.po @@ -19,7 +19,7 @@ msgstr "" #: ../../builtins/time-complexity.rst:5 msgid "Time complexity of operations on built-in types" -msgstr "" +msgstr "內建型別操作的時間複雜度" #: ../../builtins/time-complexity.rst:7 msgid "" @@ -28,6 +28,9 @@ msgid "" "performance characteristics. Additionally, the listed costs assume exact " "built-in types, as instances of subclasses may have different costs." msgstr "" +"本頁記錄了 CPython 中各種內建型別操作的時間複雜度。其他 Python 實作可能有不同" +"的效能特性。此外,所列出的成本皆假設為確切的內建型別,因為子類別的實例可能有" +"不同的成本。" #: ../../builtins/time-complexity.rst:12 msgid "" @@ -36,10 +39,13 @@ msgid "" "number of elements currently in the container, and *k* is the value of a " "numeric parameter, such as an index or a repeat count." msgstr "" +"我們使用 |big O notation|_ 來描述一項操作的執行時間如何隨著輸入大小而成長。除" +"非另有說明,*n* 代表容器中目前的元素數量,*k* 則代表數值參數的值,例如索引或" +"重複次數。" #: ../../builtins/time-complexity.rst:22 msgid ":class:`!list`" -msgstr "" +msgstr ":class:`!list`" #: ../../builtins/time-complexity.rst:24 msgid "" @@ -50,6 +56,10 @@ msgid "" "move). If you need to add or remove at both ends, consider using a :class:" "`collections.deque` instead." msgstr "" +"list 是可變的序列;如需更多實作細節,請參閱\\ :ref:`how-are-lists-" +"implemented`\\ 。最大的成本來自於成長超出目前配置的大小(因為所有元素都必須搬" +"移),或是在接近開頭處插入或刪除元素(因為之後的所有元素都必須搬移)。如果你" +"需要在兩端新增或移除元素,可以考慮改用 :class:`collections.deque`\\ 。" #: ../../builtins/time-complexity.rst:34 ../../builtins/time-complexity.rst:85 #: ../../builtins/time-complexity.rst:121 @@ -58,7 +68,7 @@ msgstr "" #: ../../builtins/time-complexity.rst:232 #: ../../builtins/time-complexity.rst:259 msgid "Operation" -msgstr "" +msgstr "操作" #: ../../builtins/time-complexity.rst:35 ../../builtins/time-complexity.rst:86 #: ../../builtins/time-complexity.rst:122 @@ -67,11 +77,11 @@ msgstr "" #: ../../builtins/time-complexity.rst:233 #: ../../builtins/time-complexity.rst:260 msgid "Complexity" -msgstr "" +msgstr "複雜度" #: ../../builtins/time-complexity.rst:36 msgid "Copy (``l.copy()``)" -msgstr "" +msgstr "複製(``l.copy()``)" #: ../../builtins/time-complexity.rst:37 ../../builtins/time-complexity.rst:51 #: ../../builtins/time-complexity.rst:68 ../../builtins/time-complexity.rst:70 @@ -89,11 +99,11 @@ msgstr "" #: ../../builtins/time-complexity.rst:270 #: ../../builtins/time-complexity.rst:272 msgid "*O*\\ (*n*)" -msgstr "" +msgstr "*O*\\ (*n*)" #: ../../builtins/time-complexity.rst:38 msgid "Append (``l.append(x)``) [1]_" -msgstr "" +msgstr "附加(``l.append(x)``) [1]_" #: ../../builtins/time-complexity.rst:39 ../../builtins/time-complexity.rst:45 #: ../../builtins/time-complexity.rst:47 ../../builtins/time-complexity.rst:72 @@ -120,114 +130,116 @@ msgstr "" #: ../../builtins/time-complexity.rst:268 #: ../../builtins/time-complexity.rst:274 msgid "*O*\\ (1)" -msgstr "" +msgstr "*O*\\ (1)" #: ../../builtins/time-complexity.rst:40 msgid "Pop (``l.pop(k)``) [1]_ [2]_" -msgstr "" +msgstr "彈出(``l.pop(k)``) [1]_ [2]_" #: ../../builtins/time-complexity.rst:41 ../../builtins/time-complexity.rst:43 #: ../../builtins/time-complexity.rst:49 msgid "*O*\\ (*n* - *k*)" -msgstr "" +msgstr "*O*\\ (*n* - *k*)" #: ../../builtins/time-complexity.rst:42 msgid "Insert (``l.insert(k, x)``) [1]_ [2]_" -msgstr "" +msgstr "插入(``l.insert(k, x)``) [1]_ [2]_" #: ../../builtins/time-complexity.rst:44 msgid "Get item (``l[k]``)" -msgstr "" +msgstr "取得項目(``l[k]``)" #: ../../builtins/time-complexity.rst:46 msgid "Set item (``l[k] = x``)" -msgstr "" +msgstr "設定項目(``l[k] = x``)" #: ../../builtins/time-complexity.rst:48 msgid "Delete item (``del l[k]``) [2]_" -msgstr "" +msgstr "刪除項目(``del l[k]``) [2]_" #: ../../builtins/time-complexity.rst:50 ../../builtins/time-complexity.rst:97 #: ../../builtins/time-complexity.rst:215 #: ../../builtins/time-complexity.rst:269 msgid "Iteration" -msgstr "" +msgstr "疊代" #: ../../builtins/time-complexity.rst:52 msgid "Get slice (``l[i:j]``)" -msgstr "" +msgstr "取得切片(``l[i:j]``)" #: ../../builtins/time-complexity.rst:53 ../../builtins/time-complexity.rst:92 #: ../../builtins/time-complexity.rst:204 msgid "*O*\\ (*j* - *i*)" -msgstr "" +msgstr "*O*\\ (*j* - *i*)" #: ../../builtins/time-complexity.rst:54 msgid "Set slice (``l[i:j] = t``) [1]_" -msgstr "" +msgstr "設定切片(``l[i:j] = t``) [1]_" #: ../../builtins/time-complexity.rst:55 msgid "" "*O*\\ (*j* - *i*) if len(*t*) == *j* - *i*, otherwise *O*\\ (*n* - *i* + " "len(*t*))" msgstr "" +"當 len(*t*) 等於 *j* - *i* 時為 *O*\\ (*j* - *i*),否則為 *O*\\ (*n* - *i* + " +"len(*t*))" #: ../../builtins/time-complexity.rst:57 msgid "Delete slice (``del l[i:j]``)" -msgstr "" +msgstr "刪除切片(``del l[i:j]``)" #: ../../builtins/time-complexity.rst:58 msgid "*O*\\ (*n* - *i*)" -msgstr "" +msgstr "*O*\\ (*n* - *i*)" #: ../../builtins/time-complexity.rst:59 msgid "Extend (``l.extend(t)``) [1]_ [3]_" -msgstr "" +msgstr "擴充(``l.extend(t)``) [1]_ [3]_" #: ../../builtins/time-complexity.rst:60 ../../builtins/time-complexity.rst:134 msgid "*O*\\ (len(*t*))" -msgstr "" +msgstr "*O*\\ (len(*t*))" #: ../../builtins/time-complexity.rst:61 msgid "Sort (``l.sort()``) [4]_" -msgstr "" +msgstr "排序(``l.sort()``) [4]_" #: ../../builtins/time-complexity.rst:62 msgid "*O*\\ (*n* log *n*)" -msgstr "" +msgstr "*O*\\ (*n* log *n*)" #: ../../builtins/time-complexity.rst:63 msgid "Concatenate (``l1 + l2``)" -msgstr "" +msgstr "連接(``l1 + l2``)" #: ../../builtins/time-complexity.rst:64 msgid "*O*\\ (len(*l1*) + len(*l2*))" -msgstr "" +msgstr "*O*\\ (len(*l1*) + len(*l2*))" #: ../../builtins/time-complexity.rst:65 msgid "Multiply (``l * k``)" -msgstr "" +msgstr "乘法(``l * k``)" #: ../../builtins/time-complexity.rst:66 ../../builtins/time-complexity.rst:96 #: ../../builtins/time-complexity.rst:208 msgid "*O*\\ (*nk*)" -msgstr "" +msgstr "*O*\\ (*nk*)" #: ../../builtins/time-complexity.rst:67 msgid "``x in l``" -msgstr "" +msgstr "``x in l``" #: ../../builtins/time-complexity.rst:69 msgid "``min(l)``, ``max(l)``" -msgstr "" +msgstr "``min(l)``, ``max(l)``" #: ../../builtins/time-complexity.rst:71 msgid "Get length (``len(l)``) [5]_" -msgstr "" +msgstr "取得長度(``len(l)``) [5]_" #: ../../builtins/time-complexity.rst:76 msgid ":class:`!tuple`" -msgstr "" +msgstr ":class:`!tuple`" #: ../../builtins/time-complexity.rst:78 msgid "" @@ -235,46 +247,49 @@ msgid "" "change, there are no insertion or deletion costs, and making a copy simply " "returns the same object, so is constant time (*O*\\ (1))." msgstr "" +":class:`tuple` 是一個 :term:`immutable`\\ (不可變的)序列。因為 tuple 永遠不" +"會改變,所以沒有插入或刪除的成本,而複製只會回傳同一個物件,因此是常數時間" +"(*O*\\ (1))。" #: ../../builtins/time-complexity.rst:87 msgid "Copy (``tuple(t)``)" -msgstr "" +msgstr "複製(``tuple(t)``)" #: ../../builtins/time-complexity.rst:89 msgid "Get item (``t[k]``)" -msgstr "" +msgstr "取得項目(``t[k]``)" #: ../../builtins/time-complexity.rst:91 msgid "Get slice (``t[i:j]``)" -msgstr "" +msgstr "取得切片(``t[i:j]``)" #: ../../builtins/time-complexity.rst:93 msgid "Concatenate (``t1 + t2``)" -msgstr "" +msgstr "連接(``t1 + t2``)" #: ../../builtins/time-complexity.rst:94 msgid "*O*\\ (len(*t1*) + len(*t2*))" -msgstr "" +msgstr "*O*\\ (len(*t1*) + len(*t2*))" #: ../../builtins/time-complexity.rst:95 msgid "Multiply (``t * k``)" -msgstr "" +msgstr "乘法(``t * k``)" #: ../../builtins/time-complexity.rst:99 msgid "``x in t``" -msgstr "" +msgstr "``x in t``" #: ../../builtins/time-complexity.rst:101 msgid "``min(t)``, ``max(t)``" -msgstr "" +msgstr "``min(t)``, ``max(t)``" #: ../../builtins/time-complexity.rst:103 msgid "Get length (``len(t)``) [5]_" -msgstr "" +msgstr "取得長度(``len(t)``) [5]_" #: ../../builtins/time-complexity.rst:108 msgid ":class:`!dict`" -msgstr "" +msgstr ":class:`!dict`" #: ../../builtins/time-complexity.rst:110 msgid "" @@ -286,42 +301,47 @@ msgid "" "also assume that hashing and comparing a key is *O*\\ (1). For more detail " "on the implementation, see :ref:`how-are-dictionaries-implemented`." msgstr "" +"針對 dict 物件所列出的時間為平均情況下的時間,因為這些數字假設物件的雜湊函式" +"足夠穩健,使碰撞情況不常發生。它們也假設鍵在所有可能鍵值的集合中分佈均勻。在" +"最壞情況下,當所有鍵都雜湊到相同的值時,以下每個 *O*\\ (1) 的操作反而會花費 " +"*O*\\ (*n*) 的時間。它們也假設雜湊和比較一個鍵的成本是 *O*\\ (1)。如需更多實" +"作細節,請參閱\\ :ref:`how-are-dictionaries-implemented`\\ 。" #: ../../builtins/time-complexity.rst:123 msgid "``key in d``" -msgstr "" +msgstr "``key in d``" #: ../../builtins/time-complexity.rst:125 msgid "Copy (``d.copy()``) [7]_" -msgstr "" +msgstr "複製(``d.copy()``) [7]_" #: ../../builtins/time-complexity.rst:127 msgid "Get item (``d[key]``, ``d.get(key)``)" -msgstr "" +msgstr "取得項目(``d[key]``、``d.get(key)``)" #: ../../builtins/time-complexity.rst:129 msgid "Set item (``d[key] = value``) [1]_" -msgstr "" +msgstr "設定項目(``d[key] = value``) [1]_" #: ../../builtins/time-complexity.rst:131 msgid "Delete item (``del d[key]``, ``d.pop(key)``)" -msgstr "" +msgstr "刪除項目(``del d[key]``、``d.pop(key)``)" #: ../../builtins/time-complexity.rst:133 msgid "Update (``d.update(t)``, ``d |= t``) [1]_ [3]_ [7]_" -msgstr "" +msgstr "更新(``d.update(t)``、``d |= t``) [1]_ [3]_ [7]_" #: ../../builtins/time-complexity.rst:135 msgid "Iteration [7]_" -msgstr "" +msgstr "疊代 [7]_" #: ../../builtins/time-complexity.rst:137 msgid "Get length (``len(d)``) [5]_" -msgstr "" +msgstr "取得長度(``len(d)``) [5]_" #: ../../builtins/time-complexity.rst:142 msgid ":class:`!set`, :class:`!frozenset`" -msgstr "" +msgstr ":class:`!set`、:class:`!frozenset`" #: ../../builtins/time-complexity.rst:144 msgid "" @@ -330,6 +350,9 @@ msgid "" "operations instead take *O*\\ (*n*) time, and operations that look up every " "element degrade accordingly." msgstr "" +"請參閱 :class:`dict`\\ ,因為 :class:`set` 和 :class:`frozenset` 的實作方式相" +"似,相同的注意事項也同樣適用。在最壞情況下,*O*\\ (1) 的操作反而需要花費 " +"*O*\\ (*n*) 的時間,而查找每個元素的操作也會相應地變差。" #: ../../builtins/time-complexity.rst:149 msgid "" @@ -337,89 +360,94 @@ msgid "" "discarding, or the in-place update operations. The others below apply to it " "at the same costs." msgstr "" +":class:`frozenset` 是 :term:`immutable`\\ (不可變的),因此不支援新增、捨棄" +"或原地更新操作。以下其他操作則以相同的成本適用於它。" #: ../../builtins/time-complexity.rst:158 msgid "``x in s``" -msgstr "" +msgstr "``x in s``" #: ../../builtins/time-complexity.rst:160 msgid "Copy (``s.copy()``) [6]_ [7]_" -msgstr "" +msgstr "複製(``s.copy()``) [6]_ [7]_" #: ../../builtins/time-complexity.rst:162 msgid "Add (``s.add(x)``) [1]_" -msgstr "" +msgstr "新增(``s.add(x)``) [1]_" #: ../../builtins/time-complexity.rst:164 msgid "Discard (``s.discard(x)``, ``s.remove(x)``)" -msgstr "" +msgstr "捨棄(``s.discard(x)``、``s.remove(x)``)" #: ../../builtins/time-complexity.rst:166 msgid "Union (``s1 | s2``, ``s1.union(s2)``) [7]_" -msgstr "" +msgstr "聯集(``s1 | s2``、``s1.union(s2)``) [7]_" #: ../../builtins/time-complexity.rst:167 #: ../../builtins/time-complexity.rst:179 msgid "*O*\\ (len(*s1*) + len(*s2*))" -msgstr "" +msgstr "*O*\\ (len(*s1*) + len(*s2*))" #: ../../builtins/time-complexity.rst:168 msgid "Update (``s1 |= s2``, ``s1.update(s2)``) [1]_ [7]_" -msgstr "" +msgstr "更新(``s1 |= s2``、``s1.update(s2)``) [1]_ [7]_" #: ../../builtins/time-complexity.rst:169 #: ../../builtins/time-complexity.rst:181 msgid "*O*\\ (len(*s2*))" -msgstr "" +msgstr "*O*\\ (len(*s2*))" #: ../../builtins/time-complexity.rst:170 msgid "Intersection (``s1 & s2``, ``s1.intersection(s2)``) [7]_ [8]_" -msgstr "" +msgstr "交集(``s1 & s2``、``s1.intersection(s2)``) [7]_ [8]_" #: ../../builtins/time-complexity.rst:171 #: ../../builtins/time-complexity.rst:173 #: ../../builtins/time-complexity.rst:177 msgid "*O*\\ (min(len(*s1*), len(*s2*)))" -msgstr "" +msgstr "*O*\\ (min(len(*s1*), len(*s2*)))" #: ../../builtins/time-complexity.rst:172 msgid "" "Intersection update (``s1 &= s2``, ``s1.intersection_update(s2)``) [1]_ [7]_ " "[8]_" msgstr "" +"交集更新(``s1 &= s2``、``s1.intersection_update(s2)``) [1]_ [7]_ [8]_" #: ../../builtins/time-complexity.rst:174 msgid "Difference (``s1 - s2``, ``s1.difference(s2)``) [7]_ [9]_" -msgstr "" +msgstr "差集(``s1 - s2``、``s1.difference(s2)``) [7]_ [9]_" #: ../../builtins/time-complexity.rst:175 msgid "*O*\\ (len(*s1*))" -msgstr "" +msgstr "*O*\\ (len(*s1*))" #: ../../builtins/time-complexity.rst:176 msgid "" "Difference update (``s1 -= s2``, ``s1.difference_update(s2)``) [1]_ [7]_ [8]_" -msgstr "" +msgstr "差集更新(``s1 -= s2``、``s1.difference_update(s2)``) [1]_ [7]_ [8]_" #: ../../builtins/time-complexity.rst:178 msgid "" "Symmetric difference (``s1 ^ s2``, ``s1.symmetric_difference(s2)``) [7]_" -msgstr "" +msgstr "對稱差集(``s1 ^ s2``、``s1.symmetric_difference(s2)``) [7]_" #: ../../builtins/time-complexity.rst:180 msgid "" "Symmetric difference update (``s1 ^= s2``, ``s1." "symmetric_difference_update(s2)``) [1]_ [7]_" msgstr "" +"對稱差集更新(``s1 ^= s2``、``s1.symmetric_difference_update(s2)``) [1]_ " +"[7]_" #: ../../builtins/time-complexity.rst:182 #: ../../builtins/time-complexity.rst:217 msgid "Get length (``len(s)``) [5]_" -msgstr "" +msgstr "取得長度(``len(s)``) [5]_" #: ../../builtins/time-complexity.rst:187 msgid ":class:`!str`, :class:`!bytes`, :class:`!bytearray`" -msgstr "" +msgstr ":class:`!str`、:class:`!bytes`、:class:`!bytearray`" #: ../../builtins/time-complexity.rst:189 msgid "" @@ -431,46 +459,51 @@ msgid "" "k]``) only advances the start of the buffer instead of moving the remaining " "bytes, and is amortized *O*\\ (1)." msgstr "" +":class:`str` 和 :class:`bytes` 物件分別是字元和位元組的不可變序列。和 tuple " +"一樣,複製它們會回傳原始物件。:class:`bytearray` 是可變的,並額外支援 :class:" +"`list` 的可變操作(:meth:`!sort` 除外),且成本相同。不過,使用 ``del``\\ " +"(``del b[0]``、``del b[:k]``)在開頭刪除時,只會推進緩衝區的起始位置,而不會" +"搬移剩餘的位元組,因此是攤銷 *O*\\ (1)。" #: ../../builtins/time-complexity.rst:201 msgid "Get item (``s[k]``)" -msgstr "" +msgstr "取得項目(``s[k]``)" #: ../../builtins/time-complexity.rst:203 msgid "Get slice (``s[i:j]``)" -msgstr "" +msgstr "取得切片(``s[i:j]``)" #: ../../builtins/time-complexity.rst:205 msgid "Concatenate (``s + t``) [10]_" -msgstr "" +msgstr "連接(``s + t``) [10]_" #: ../../builtins/time-complexity.rst:206 msgid "*O*\\ (len(*s*) + len(*t*))" -msgstr "" +msgstr "*O*\\ (len(*s*) + len(*t*))" #: ../../builtins/time-complexity.rst:207 msgid "Multiply (``s * k``)" -msgstr "" +msgstr "乘法(``s * k``)" #: ../../builtins/time-complexity.rst:209 msgid "Substring search (``x in s``, ``s.find(x)``, ``s.index(x)``) [11]_" -msgstr "" +msgstr "子字串搜尋(``x in s``、``s.find(x)``、``s.index(x)``) [11]_" #: ../../builtins/time-complexity.rst:211 msgid "Reverse substring search (``s.rfind(x)``, ``s.rindex(x)``) [11]_ [12]_" -msgstr "" +msgstr "反向子字串搜尋(``s.rfind(x)``、``s.rindex(x)``) [11]_ [12]_" #: ../../builtins/time-complexity.rst:212 msgid "*O*\\ (*n* × len(*x*))" -msgstr "" +msgstr "*O*\\ (*n* × len(*x*))" #: ../../builtins/time-complexity.rst:213 msgid "Encode or decode [13]_" -msgstr "" +msgstr "編碼或解碼 [13]_" #: ../../builtins/time-complexity.rst:222 msgid ":class:`!memoryview`" -msgstr "" +msgstr ":class:`!memoryview`" #: ../../builtins/time-complexity.rst:224 msgid "" @@ -479,38 +512,41 @@ msgid "" "copying. In particular, slicing a memory view returns a new view onto the " "same buffer." msgstr "" +":class:`memoryview` 物件讓 Python 程式碼得以在不複製的情況下,存取支援\\ :" +"ref:`緩衝區協定 `\\ 的物件之內部資料。特別是,對 memoryview 進" +"行切片會回傳指向同一緩衝區的新檢視。" #: ../../builtins/time-complexity.rst:234 msgid "Create (``memoryview(obj)``)" -msgstr "" +msgstr "建立(``memoryview(obj)``)" #: ../../builtins/time-complexity.rst:236 msgid "Get item (``v[k]``)" -msgstr "" +msgstr "取得項目(``v[k]``)" #: ../../builtins/time-complexity.rst:238 msgid "Get slice (``v[i:j]``)" -msgstr "" +msgstr "取得切片(``v[i:j]``)" #: ../../builtins/time-complexity.rst:240 msgid "Index (``v.index(x)``) [11]_ [14]_" -msgstr "" +msgstr "索引(``v.index(x)``) [11]_ [14]_" #: ../../builtins/time-complexity.rst:242 msgid "Count (``v.count(x)``) [14]_" -msgstr "" +msgstr "計數(``v.count(x)``) [14]_" #: ../../builtins/time-complexity.rst:244 msgid "Convert to bytes (``v.tobytes()``, ``bytes(v)``)" -msgstr "" +msgstr "轉換為 bytes(``v.tobytes()``、``bytes(v)``)" #: ../../builtins/time-complexity.rst:246 msgid "Get length (``len(v)``) [5]_" -msgstr "" +msgstr "取得長度(``len(v)``) [5]_" #: ../../builtins/time-complexity.rst:251 msgid ":class:`!range`" -msgstr "" +msgstr ":class:`!range`" #: ../../builtins/time-complexity.rst:253 msgid "" @@ -518,34 +554,36 @@ msgid "" "*stop* and *step* values, so most operations do not depend on the length of " "the range." msgstr "" +":class:`range` 物件會根據其 *start* 值、*stop* 值和 *step* 值即時計算其項目," +"因此大多數操作並不取決於該 range 的長度。" #: ../../builtins/time-complexity.rst:261 msgid "Get item (``r[k]``)" -msgstr "" +msgstr "取得項目(``r[k]``)" #: ../../builtins/time-complexity.rst:263 msgid "Get slice (``r[i:j]``)" -msgstr "" +msgstr "取得切片(``r[i:j]``)" #: ../../builtins/time-complexity.rst:265 msgid "``x in r`` [15]_" -msgstr "" +msgstr "``x in r`` [15]_" #: ../../builtins/time-complexity.rst:267 msgid "Index and count (``r.index(x)``, ``r.count(x)``) [15]_" -msgstr "" +msgstr "索引與計數(``r.index(x)``、``r.count(x)``) [15]_" #: ../../builtins/time-complexity.rst:271 msgid "``min(r)``, ``max(r)``" -msgstr "" +msgstr "``min(r)``, ``max(r)``" #: ../../builtins/time-complexity.rst:273 msgid "Get length (``len(r)``) [5]_" -msgstr "" +msgstr "取得長度(``len(r)``) [5]_" #: ../../builtins/time-complexity.rst:278 msgid "Notes" -msgstr "" +msgstr "註解" #: ../../builtins/time-complexity.rst:280 msgid "" @@ -553,6 +591,8 @@ msgid "" "underlying storage is resized, but this cost is spread over many operations, " "depending on the history of the container." msgstr "" +"攤銷。當底層儲存空間被調整大小時,個別操作偶爾可能會是 *O*\\ (*n*),但這項成" +"本會依容器的操作歷史分攤到多次操作之中。" #: ../../builtins/time-complexity.rst:284 msgid "" @@ -564,12 +604,17 @@ msgid "" "of the list, takes *O*\\ (*n*/2) = *O*\\ (*n*) operations; and operating at " "the end of the list moves nothing and is *O*\\ (1)." msgstr "" +"彈出或刪除大小為 *n* 的 list 中索引 *k* 處的元素,會將 *k* 之後的所有元素向左" +"移動一格,共搬移 *n* - *k* - 1 個元素;在索引 *k* 處插入則會將從 *k* 開始的元" +"素向右移動一格,共搬移 *n* - *k* 個元素。最壞情況是索引 0,此時必須搬移 list " +"其餘的所有元素;平均情況(list 中間的索引)需要 *O*\\ (*n*/2) = *O*\\ (*n*) " +"次操作;而在 list 尾端操作則不需搬移任何元素,為 *O*\\ (1)。" #: ../../builtins/time-complexity.rst:293 msgid "" "Plus the cost of iterating over *t*, which may be expensive for an arbitrary " "iterable." -msgstr "" +msgstr "加上疊代 *t* 的成本,這對任意的可疊代物件而言可能會很昂貴。" #: ../../builtins/time-complexity.rst:296 msgid "" @@ -577,17 +622,19 @@ msgid "" "already sorted or reverse-sorted takes only *O*\\ (*n*) comparisons. See :" "source:`Objects/listsort.txt` for more information." msgstr "" +"這是最壞情況。排序具有自適應性,已排序或反向排序的輸入只需要 *O*\\ (*n*) 次比" +"較。詳情請參閱\\ :source:`Objects/listsort.txt`\\ 。" #: ../../builtins/time-complexity.rst:300 msgid "" "The number of elements is stored in the object, so ``len()`` does not need " "to count them." -msgstr "" +msgstr "元素的數量已經儲存在物件中,因此 ``len()`` 不需要逐一計算它們。" #: ../../builtins/time-complexity.rst:303 msgid "" "Copying a :class:`frozenset` is *O*\\ (1) as it returns the original object." -msgstr "" +msgstr "複製 :class:`frozenset` 是 *O*\\ (1),因為它會回傳原始物件。" #: ../../builtins/time-complexity.rst:306 msgid "" @@ -596,14 +643,17 @@ msgid "" "take time proportional to the container's former size, until a later " "insertion triggers a resize." msgstr "" +"這些操作會掃描容器的內部雜湊表,而該雜湊表在元素被移除時並不會縮小。在移除大" +"部分元素之後,這些操作仍然需要花費與容器先前大小成正比的時間,直到之後的一次" +"插入觸發大小調整為止。" #: ../../builtins/time-complexity.rst:311 msgid "*O*\\ (len(*t*)) if *t* is not a set." -msgstr "" +msgstr "如果 *t* 不是 set,則為 *O*\\ (len(*t*))。" #: ../../builtins/time-complexity.rst:313 msgid "*O*\\ (len(*s*) + len(*t*)) if *t* is not a set." -msgstr "" +msgstr "如果 *t* 不是 set,則為 *O*\\ (len(*s*) + len(*t*))。" #: ../../builtins/time-complexity.rst:315 msgid "" @@ -612,12 +662,17 @@ msgid "" "the :ref:`note on concatenating immutable sequences ` for alternatives." msgstr "" +"每一次連接都會建立一個新物件,因此在迴圈中連接許多片段來組成一個字串,其時間" +"會與總長度的平方成正比。其他替代做法請參閱\\ :ref:`關於連接不可變序列的附註 " +"`\\ 。" #: ../../builtins/time-complexity.rst:320 msgid "" "With *start* and *end* arguments, *n* is the length of the region searched " "rather than of *s*, and unlike slicing nothing is copied." msgstr "" +"當帶有 *start* 和 *end* 引數時,*n* 是搜尋範圍的長度,而不是 *s* 的長度,且與" +"切片不同的是,不會複製任何內容。" #: ../../builtins/time-complexity.rst:323 msgid "" @@ -626,19 +681,25 @@ msgid "" "case, described in :source:`Objects/stringlib/stringlib_find_two_way_notes." "txt`." msgstr "" +"這是最壞情況。對於一般的輸入,反向搜尋為 *O*\\ (*n*)。正向搜尋則改用一種更精" +"密的演算法,其最壞情況為線性時間,詳情請參閱\\ :source:`Objects/stringlib/" +"stringlib_find_two_way_notes.txt`\\ 。" #: ../../builtins/time-complexity.rst:328 msgid "This assumes a codec that does a constant amount of work per character." -msgstr "" +msgstr "這是假設編解碼器對每個字元執行固定量的工作。" #: ../../builtins/time-complexity.rst:330 msgid "" "These unpack and compare each element individually, so they are much slower " "than the equivalent :class:`bytes` methods." msgstr "" +"這些操作會逐一拆解並比較每個元素,因此比對應的 :class:`bytes` 方法慢得多。" #: ../../builtins/time-complexity.rst:333 msgid "" "Assuming :class:`int` or :class:`bool` arguments. For other types, the range " "is searched like any other sequence in *O*\\ (*n*) time." msgstr "" +"假設引數為 :class:`int` 或 :class:`bool`。對於其他型別,range 會像其他一般序" +"列一樣被搜尋,花費 *O*\\ (*n*) 的時間。" diff --git a/c-api/arg.po b/c-api/arg.po index 4613bce437..ca48a89bcb 100644 --- a/c-api/arg.po +++ b/c-api/arg.po @@ -742,6 +742,10 @@ msgid "" "corresponding C variable(s). For example, the format string ``\"OO|OO\"`` " "corresponds to the Python signature ``f(a, b, c=None, d=None)``." msgstr "" +"表示 Python 引數列表中剩餘的引數為可選的。與可選引數相對應的 C 變數應初始化為" +"其預設值 --- 當可選引數未被指定時,:c:func:`PyArg_ParseTuple` 不會更動相應 C " +"變數的內容。例如,格式字串 ``\"OO|OO\"`` 對應於 Python 簽名 ``f(a, b, " +"c=None, d=None)``。" #: ../../c-api/arg.rst:398 msgid "``$``" @@ -756,6 +760,11 @@ msgid "" "corresponds to the Python signature ``f(a, b=None, *, c=None)``, and the " "format string ``\"OO$OO\"`` corresponds to ``f(a, b, *, c, d)``." msgstr "" +"僅限 :c:func:`PyArg_ParseTupleAndKeywords`:表示 Python 引數列表中剩餘的引數" +"皆為僅限關鍵字引數。若 ``$`` 之前指定了 ``|``,則它們為可選;否則為必要。``|" +"`` 不能在 ``$`` 之後指定。例如,格式字串 ``\"O|O$O\"`` 對應到 Python 簽名 " +"``f(a, b=None, *, c=None)``,格式字串 ``\"OO$OO\"`` 則對應到 ``f(a, b, *, c, " +"d)``。" #: ../../c-api/arg.rst:410 msgid "``:``" diff --git a/c-api/buffer.po b/c-api/buffer.po index e2349ec04b..f1eb53896a 100644 --- a/c-api/buffer.po +++ b/c-api/buffer.po @@ -362,11 +362,8 @@ msgid "" msgstr "" #: ../../c-api/buffer.rst:266 -#, fuzzy msgid "This is an alias to :c:macro:`PyBUF_WRITABLE`." -msgstr "" -"這是 :c:macro:`PyBUF_WRITABLE` 的\\ :term:`軟性棄用 `\\ 別" -"名。" +msgstr "此為 :c:macro:`PyBUF_WRITABLE` 的別名。" #: ../../c-api/buffer.rst:272 msgid "" diff --git a/c-api/bytearray.po b/c-api/bytearray.po index ddbd354ac6..465ce4df37 100644 --- a/c-api/bytearray.po +++ b/c-api/bytearray.po @@ -34,6 +34,9 @@ msgid "" "extra byte is not counted in :c:func:`PyByteArray_Size` nor in the *len* " "arguments of the functions below." msgstr "" +":c:type:`PyByteArrayObject` 的內部緩衝區永遠會在結尾額外包含一個 null byte," +"以與以 null 結尾的 C 字串相容。這個額外的位元組不會被計入 :c:func:" +"`PyByteArray_Size`,也不會計入下列函式的 *len* 引數中。" #: ../../c-api/bytearray.rst:24 msgid "" diff --git a/c-api/bytes.po b/c-api/bytes.po index 66499d06ff..d6f0bfa29e 100644 --- a/c-api/bytes.po +++ b/c-api/bytes.po @@ -34,6 +34,9 @@ msgid "" "extra byte is not counted in :c:func:`PyBytes_Size` nor in the various " "*length* and *size* arguments of the functions below." msgstr "" +":c:type:`PyBytesObject` 的內部緩衝區永遠會在結尾額外包含一個 null byte,以與" +"以 null 結尾的 C 字串相容。這個額外的位元組不會被計入 :c:func:" +"`PyBytes_Size`,也不會計入下列函式的各個 *length* 和 *size* 引數中。" #: ../../c-api/bytes.rst:23 msgid "This subtype of :c:type:`PyObject` represents a Python bytes object." @@ -320,6 +323,10 @@ msgid "" "\"stolen\", the value of *\\*bytes* will be set to ``NULL``, and the " "appropriate exception will be set." msgstr "" +"在 *\\*bytes* 中建立一個新的 bytes 物件,其內容為 *newpart* 附加到 *bytes* 之" +"後的結果;呼叫者將擁有新的參照。*bytes* 舊值的參照將被「:term:`竊取 " +"`」。如果無法建立新物件,*bytes* 的舊參照仍將被「竊取」,*\\*bytes* 的" +"值將被設為 ``NULL``,並會設定適當的例外。" #: ../../c-api/bytes.rst:197 ../../c-api/bytes.rst:207 msgid "" diff --git a/c-api/code.po b/c-api/code.po index 05252c66c1..ca4a707878 100644 --- a/c-api/code.po +++ b/c-api/code.po @@ -264,7 +264,7 @@ msgstr "" #: ../../c-api/code.rst:217 msgid "This is a function that does nothing." -msgstr "" +msgstr "此函式不執行任何操作。" #: ../../c-api/code.rst:219 msgid "" diff --git a/c-api/descriptor.po b/c-api/descriptor.po index 09817d0e63..2e082c748d 100644 --- a/c-api/descriptor.po +++ b/c-api/descriptor.po @@ -42,6 +42,8 @@ msgid "" "Create a new get-set descriptor for extension type *type* from the :c:type:" "`PyGetSetDef` structure *getset*." msgstr "" +"從 :c:type:`PyGetSetDef` 結構 *getset* 為擴充型別 *type* 建立一個新的 get-" +"set 描述器。" #: ../../c-api/descriptor.rst:21 msgid "" @@ -50,6 +52,10 @@ msgid "" "of descriptor created for entries in :c:member:`~PyTypeObject.tp_getset`, " "and it appears in Python as a :class:`types.GetSetDescriptorType` object." msgstr "" +"get-set 描述器所公開的屬性是由 C 取得器 (getter) 和設定器 (setter) 函式實作" +"的,而不是直接儲存在實例中。這與 :c:member:`~PyTypeObject.tp_getset` 中各項目" +"所建立的是同一種描述器,並在 Python 中以 :class:`types.GetSetDescriptorType` " +"物件的形式呈現。" #: ../../c-api/descriptor.rst:26 ../../c-api/descriptor.rst:39 #: ../../c-api/descriptor.rst:70 ../../c-api/descriptor.rst:101 @@ -58,12 +64,16 @@ msgid "" "On success, return a :term:`strong reference` to the descriptor. Return " "``NULL`` with an exception set on failure." msgstr "" +"成功時,回傳一個對描述器的 :term:`strong reference`\\ 。失敗時,回傳 " +"``NULL`` 並設定例外。" #: ../../c-api/descriptor.rst:31 msgid "" "Create a new member descriptor for extension type *type* from the :c:type:" "`PyMemberDef` structure *member*." msgstr "" +"從 :c:type:`PyMemberDef` 結構 *member* 為擴充型別 *type* 建立一個新的 member " +"描述器。" #: ../../c-api/descriptor.rst:34 msgid "" @@ -72,6 +82,9 @@ msgid "" "member:`~PyTypeObject.tp_members`, and it appears in Python as a :class:" "`types.MemberDescriptorType` object." msgstr "" +"member 描述器將型別的 C 結構欄位公開為 Python 屬性。這與 :c:member:" +"`~PyTypeObject.tp_members` 中各項目所建立的是同一種描述器,並在 Python 中以 :" +"class:`types.MemberDescriptorType` 物件的形式呈現。" #: ../../c-api/descriptor.rst:44 msgid "" @@ -89,12 +102,17 @@ msgid "" "type attributes. They correspond to :class:`types.GetSetDescriptorType` " "objects in Python." msgstr "" +"此為由 :c:type:`PyGetSetDef` 結構所建立的 get-set 描述器物件的型別物件。這些" +"描述器實作了值由 C 取得器和設定器函式計算得出的屬性,並用於許多內建型別屬性。" +"它們對應於 Python 中的 :class:`types.GetSetDescriptorType` 物件。" #: ../../c-api/descriptor.rst:62 msgid "" "Create a new method descriptor for extension type *type* from the :c:type:" "`PyMethodDef` structure *meth*." msgstr "" +"從 :c:type:`PyMethodDef` 結構 *meth* 為擴充型別 *type* 建立一個新的 method 描" +"述器。" #: ../../c-api/descriptor.rst:65 msgid "" @@ -103,6 +121,9 @@ msgid "" "tp_methods`, and it appears in Python as a :class:`types." "MethodDescriptorType` object." msgstr "" +"method 描述器將 C 函式公開為型別上的方法。這與 :c:member:`~PyTypeObject." +"tp_methods` 中各項目所建立的是同一種描述器,並在 Python 中以 :class:`types." +"MethodDescriptorType` 物件的形式呈現。" #: ../../c-api/descriptor.rst:75 msgid "" @@ -111,10 +132,13 @@ msgid "" "a type, and correspond to :class:`types.MethodDescriptorType` objects in " "Python." msgstr "" +"此為由 :c:type:`PyMethodDef` 結構所建立的 method 描述器物件的型別物件。這些描" +"述器將 C 函式公開為型別上的方法,並對應於 Python 中的 :class:`types." +"MethodDescriptorType` 物件。" #: ../../c-api/descriptor.rst:83 msgid "Describes a slot wrapper used by :c:func:`PyDescr_NewWrapper`." -msgstr "" +msgstr "描述由 :c:func:`PyDescr_NewWrapper` 所使用的 slot wrapper。" #: ../../c-api/descriptor.rst:85 msgid "" @@ -122,6 +146,8 @@ msgid "" "a special method implemented by a type slot, together with the wrapper " "function used to adapt that slot to Python's calling convention." msgstr "" +"每筆 ``wrapperbase`` 紀錄都儲存了由某個型別 slot 所實作的特殊方法之 Python 可" +"見名稱與中繼資料,以及用來將該 slot 轉接為 Python 呼叫慣例的 wrapper 函式。" #: ../../c-api/descriptor.rst:91 msgid "" @@ -129,6 +155,8 @@ msgid "" "`wrapperbase` structure *base* and the wrapped slot function pointer " "*wrapped*." msgstr "" +"從 :c:struct:`wrapperbase` 結構 *base* 和被包裝的 slot 函式指標 *wrapped* 為" +"擴充型別 *type* 建立一個新的 wrapper 描述器。" #: ../../c-api/descriptor.rst:96 msgid "" @@ -137,6 +165,9 @@ msgid "" "methods such as ``__repr__`` or ``__add__``, and it appears in Python as a :" "class:`types.WrapperDescriptorType` object." msgstr "" +"wrapper 描述器將由型別 slot 實作的特殊方法公開出來。這與 CPython 為 " +"``__repr__``\\ 、``__add__`` 等基於 slot 的特殊方法所建立的是同一種描述器,並" +"在 Python 中以 :class:`types.WrapperDescriptorType` 物件的形式呈現。" #: ../../c-api/descriptor.rst:106 msgid "" @@ -152,6 +183,8 @@ msgid "" "Create a new class method descriptor for extension type *type* from the :c:" "type:`PyMethodDef` structure *method*." msgstr "" +"從 :c:type:`PyMethodDef` 結構 *method* 為擴充型別 *type* 建立一個新的 class " +"method 描述器。" #: ../../c-api/descriptor.rst:118 msgid "" @@ -160,6 +193,10 @@ msgid "" "``METH_CLASS`` entries in :c:member:`~PyTypeObject.tp_methods`, and it " "appears in Python as a :class:`types.ClassMethodDescriptorType` object." msgstr "" +"class method 描述器所公開的 C 方法,在被存取時接收的是類別本身而非實例。這" +"與 :c:member:`~PyTypeObject.tp_methods` 中 ``METH_CLASS`` 項目所建立的是同一" +"種描述器,並在 Python 中以 :class:`types.ClassMethodDescriptorType` 物件的形" +"式呈現。" #: ../../c-api/descriptor.rst:128 msgid "" @@ -174,7 +211,7 @@ msgstr "" msgid "" "Create a new bound wrapper object from the wrapper descriptor *d* and the " "instance *self*." -msgstr "" +msgstr "從 wrapper 描述器 *d* 和實例 *self* 建立一個新的已繫結 wrapper 物件。" #: ../../c-api/descriptor.rst:138 msgid "" @@ -183,12 +220,17 @@ msgid "" "accessed through an instance, and they appear in Python as :class:`types." "MethodWrapperType` objects." msgstr "" +"這是由 :c:func:`PyDescr_NewWrapper` 所建立的 wrapper 描述器的已繫結形式。當 " +"slot wrapper 透過實例被存取時,CPython 就會建立這些物件,它們在 Python 中以 :" +"class:`types.MethodWrapperType` 物件的形式出現。" #: ../../c-api/descriptor.rst:143 msgid "" "On success, return a :term:`strong reference` to the wrapper object. Return " "``NULL`` with an exception set on failure." msgstr "" +"成功時,回傳一個對 wrapper 物件的 :term:`strong reference`\\ 。失敗時,回傳 " +"``NULL`` 並設定例外。" #: ../../c-api/descriptor.rst:147 msgid "Built-in descriptors" @@ -213,6 +255,9 @@ msgid "" "extension types, and corresponds to :class:`types.ClassMethodDescriptorType` " "objects in Python." msgstr "" +"此為 C 層級 class method 描述器物件的型別物件。這是為 C 擴充型別中定義的 :" +"func:`classmethod` 所建立的描述器之型別,並對應於 Python 中的 :class:`types." +"ClassMethodDescriptorType` 物件。" #: ../../c-api/descriptor.rst:171 msgid "" diff --git a/c-api/dict.po b/c-api/dict.po index f04cedf2ca..bdcbd79524 100644 --- a/c-api/dict.po +++ b/c-api/dict.po @@ -110,6 +110,9 @@ msgid "" "on success or ``-1`` on failure. This function *does not* \":term:`steal`\" " "a reference to *val*." msgstr "" +"以 *key* 為鍵,將 *val* 插入至字典 *p* 中。*key* 必須是\\ :term:`可雜湊的 " +"`,否則將引發 :exc:`TypeError`。成功時回傳 ``0``,失敗時回傳 " +"``-1``。此函式\\ *不會*\\ 「:term:`竊取 `」對 *val* 的參照。" #: ../../c-api/dict.rst:103 msgid "" diff --git a/c-api/exceptions.po b/c-api/exceptions.po index c51b64fa45..0f82479844 100644 --- a/c-api/exceptions.po +++ b/c-api/exceptions.po @@ -156,9 +156,8 @@ msgid "" msgstr "" #: ../../c-api/exceptions.rst:124 -#, fuzzy msgid "Legacy variant of :c:func:`PyErr_DisplayException`." -msgstr "請改用 :c:func:`PyErr_GetRaisedException`。" +msgstr ":c:func:`PyErr_DisplayException` 的舊版本。" #: ../../c-api/exceptions.rst:126 msgid "" @@ -166,17 +165,20 @@ msgid "" "*value* has no traceback set, *tb* is used as its traceback. The first " "argument is ignored." msgstr "" +"將例外 *value* 及其追蹤回溯輸出到 :data:`sys.stderr`。如果 *value* 沒有設定追" +"蹤回溯,則使用 *tb* 作為其追蹤回溯。第一個引數會被忽略。" #: ../../c-api/exceptions.rst:130 msgid "" "If :data:`sys.stderr` is ``None``, nothing is printed. If :data:`sys.stderr` " "is not set, the exception is dumped to the C ``stderr`` stream instead." msgstr "" +"如果 :data:`sys.stderr` 為 ``None``,則不會輸出任何內容。如果 :data:`sys." +"stderr` 未被設定,則改將例外傾印至 C 的 ``stderr`` 串流。" #: ../../c-api/exceptions.rst:134 -#, fuzzy msgid "Use :c:func:`PyErr_DisplayException` instead." -msgstr "請改用 :c:func:`PyErr_GetRaisedException`。" +msgstr "請改用 :c:func:`PyErr_DisplayException`。" #: ../../c-api/exceptions.rst:138 msgid "Raising exceptions" @@ -562,14 +564,16 @@ msgid "" "exception if one is set. If *exc* is ``NULL``, just clear the existing " "exception." msgstr "" +"將 *exc* 設定為目前正在引發的例外,如果已經設定了現有例外,則將其清除。如果 " +"*exc* 為 ``NULL``,則只清除現有的例外。" #: ../../c-api/exceptions.rst:520 msgid "*exc* must be a valid exception or ``NULL``." -msgstr "" +msgstr "*exc* 必須是一個有效的例外或 ``NULL``。" #: ../../c-api/exceptions.rst:522 msgid "This call \":term:`steals `\" a reference to *exc*." -msgstr "" +msgstr "此呼叫「:term:`竊取 `」對 *exc* 的參照。" #: ../../c-api/exceptions.rst:531 msgid "Use :c:func:`PyErr_GetRaisedException` instead." @@ -725,6 +729,10 @@ msgid "" "arguments. This function is kept for backwards compatibility. Prefer using :" "c:func:`PyErr_SetHandledException`." msgstr "" +"設定例外資訊,如同從 ``sys.exc_info()`` 得知的資訊一般。這裡指的是一個 *已經" +"被捕捉* 的例外,而不是剛被引發的例外。此函式「:term:`竊取 `」這些引數" +"的參照。若要清除例外狀態,請為所有三個引數傳入 ``NULL``。此函式是為了向後相容" +"而保留,建議改用 :c:func:`PyErr_SetHandledException`。" #: ../../c-api/exceptions.rst:668 msgid "" @@ -741,6 +749,9 @@ msgid "" "argument). The function still \":term:`steals `\" references of all " "three arguments." msgstr "" +"引數 ``type`` 和 ``traceback`` 已不再使用,可以為 NULL。直譯器現在會從例外實" +"例(引數 ``value``)中衍生出它們。此函式仍會「:term:`竊取 `」所有三個" +"引數的參照。" #: ../../c-api/exceptions.rst:683 msgid "Signal Handling" @@ -959,6 +970,8 @@ msgid "" "clear it. There is no type check to make sure that *ctx* is an exception " "instance. This \":term:`steals `\" a reference to *ctx*." msgstr "" +"將與該例外關聯的情境設定為 *ctx*。使用 ``NULL`` 來清除它。這裡不會檢查型別以" +"確保 *ctx* 是一個例外實例。此函式「:term:`竊取 `」對 *ctx* 的參照。" #: ../../c-api/exceptions.rst:876 msgid "" @@ -975,6 +988,9 @@ msgid "" "exception instance or ``None``. This \":term:`steals `\" a reference " "to *cause*." msgstr "" +"將與該例外關聯的成因設定為 *cause*。使用 ``NULL`` 來清除它。這裡不會檢查型別" +"以確保 *cause* 是一個例外實例或 ``None``。此函式「:term:`竊取 `」對 " +"*cause* 的參照。" #: ../../c-api/exceptions.rst:889 msgid "" @@ -1145,6 +1161,10 @@ msgid "" "cycles. The following two functions facilitate this functionality. " "Effectively, these are the C equivalent to :deco:`reprlib.recursive_repr`." msgstr "" +"要為容器型別正確實作 :c:member:`~PyTypeObject.tp_repr`,需要特殊的遞迴處理。" +"除了保護堆疊之外,:c:member:`~PyTypeObject.tp_repr` 還需要追蹤物件以防止循" +"環。以下兩個函式有助於實現此功能。實際上,它們相當於 C 語言版本的 :deco:" +"`reprlib.recursive_repr`。" #: ../../c-api/exceptions.rst:1045 msgid "" diff --git a/c-api/frame.po b/c-api/frame.po index 1238270b83..de33009c26 100644 --- a/c-api/frame.po +++ b/c-api/frame.po @@ -269,7 +269,7 @@ msgstr "" msgid "" "An array of executable kinds (executor types) for frames, used for internal " "debugging and tracing." -msgstr "" +msgstr "一個 frame 可執行種類(執行器類型)的陣列,用於內部除錯與追蹤。" #: ../../c-api/frame.rst:253 msgid "" @@ -277,38 +277,40 @@ msgid "" "execution context associated with a frame (such as to filter out internal " "frames). The entries are indexed by the following constants:" msgstr "" +"除錯器和分析器(profiler)等工具可以用這個陣列來識別與某個 frame 相關聯的執行" +"環境類型(例如用來過濾掉內部 frame)。陣列項目由下列常數索引:" #: ../../c-api/frame.rst:261 msgid "Constant" -msgstr "" +msgstr "常數" #: ../../c-api/frame.rst:262 msgid "Description" -msgstr "" +msgstr "描述" #: ../../c-api/frame.rst:264 msgid "" "The frame is internal (For example: inlined) and should be skipped by tools." -msgstr "" +msgstr "此 frame 是內部的(例如:被行內化),工具應該略過它。" #: ../../c-api/frame.rst:266 msgid "The frame corresponds to a standard Python function." -msgstr "" +msgstr "此 frame 對應到一個標準的 Python 函式。" #: ../../c-api/frame.rst:268 msgid "The frame corresponds to a function defined in native code." -msgstr "" +msgstr "此 frame 對應到一個以原生程式碼定義的函式。" #: ../../c-api/frame.rst:270 msgid "The frame corresponds to a method on a class instance." -msgstr "" +msgstr "此 frame 對應到一個類別實例上的方法。" #: ../../c-api/frame.rst:272 msgid "" "Note that reading the executable kind from a frame is currently only " "possible with undocumented internal APIs." -msgstr "" +msgstr "請注意,目前只能透過未寫入文件的內部 API 從 frame 中讀取可執行種類。" #: ../../c-api/frame.rst:280 msgid "The number of entries in :c:data:`PyUnstable_ExecutableKinds`." -msgstr "" +msgstr ":c:data:`PyUnstable_ExecutableKinds` 中的項目數量。" diff --git a/c-api/gen.po b/c-api/gen.po index 3c79bc5dfd..a9586e47af 100644 --- a/c-api/gen.po +++ b/c-api/gen.po @@ -61,17 +61,16 @@ msgstr "" "此函式總是會成功執行。" #: ../../c-api/gen.rst:37 -#, fuzzy msgid "" "Create and return a new generator object based on the *frame* object. A " "reference to *frame* is \":term:`stolen `\" by this function (even on " "error). The argument must not be ``NULL``." msgstr "" -"基於 *frame* 物件建立並回傳一個新的產生器物件。此函式會取走一個對 *frame* 的" -"參照 (reference)。引數必須不為 ``NULL``。" +"基於 *frame* 物件建立並回傳一個新的產生器物件。此函式會「:term:`竊取 " +"`」對 *frame* 的一個參照(即使發生錯誤也一樣)。引數必須不為 " +"``NULL``。" #: ../../c-api/gen.rst:43 -#, fuzzy msgid "" "Create and return a new generator object based on the *frame* object, with " "``__name__`` and ``__qualname__`` set to *name* and *qualname*. A reference " @@ -79,8 +78,8 @@ msgid "" "The *frame* argument must not be ``NULL``." msgstr "" "基於 *frame* 物件建立並回傳一個新的產生器物件,其中 ``__name__`` 和 " -"``__qualname__`` 設為 *name* 和 *qualname*。此函式會取走一個對 *frame* 的參" -"照。*frame* 引數必須不為 ``NULL``。" +"``__qualname__`` 設為 *name* 和 *qualname*。此函式會「:term:`竊取 `」" +"對 *frame* 的一個參照(即使發生錯誤也一樣)。*frame* 引數必須不為 ``NULL``。" #: ../../c-api/gen.rst:51 msgid "" @@ -107,14 +106,14 @@ msgstr "" "AsyncGeneratorType` 使用。" #: ../../c-api/gen.rst:70 -#, fuzzy msgid "" "Create a new asynchronous generator wrapping *frame*, with ``__name__`` and " "``__qualname__`` set to *name* and *qualname*. *frame* is \":term:`stolen " "`\" by this function (even on error) and must not be ``NULL``." msgstr "" "建立一個包裝 *frame* 的非同步產生器,並將 ``__name__`` 和 ``__qualname__`` 設" -"為 *name* 和 *qualname*。*frame* 會被此函式取走,且不得為 ``NULL``。" +"為 *name* 和 *qualname*。*frame* 會被此函式「:term:`竊取 `」(即使發生" +"錯誤也一樣),且不得為 ``NULL``。" #: ../../c-api/gen.rst:75 msgid "" @@ -138,11 +137,8 @@ msgid "Deprecated API" msgstr "已棄用的 API" #: ../../c-api/gen.rst:94 -#, fuzzy msgid "This is an API that was included in Python's C API by mistake." -msgstr "" -"這是一個被\\ :term:`軟性棄用 `\\ 的 API,它被錯誤地包含在 " -"Python 的 C API 中。" +msgstr "這是一個被錯誤地包含在 Python 的 C API 中的 API。" #: ../../c-api/gen.rst:97 msgid "It is solely here for completeness; do not use this API." diff --git a/c-api/init_config.po b/c-api/init_config.po index 9d78e53e21..f798b68e7f 100644 --- a/c-api/init_config.po +++ b/c-api/init_config.po @@ -1091,6 +1091,8 @@ msgid "" "The function now replaces :data:`sys.flags` (create a new object), instead " "of modifying :data:`sys.flags` in-place." msgstr "" +"此函式現在會取代 :data:`sys.flags`\\(建立新物件),而非原地修改 :data:`sys." +"flags`。" #: ../../c-api/init_config.rst:634 msgid "PyConfig C API" @@ -1922,14 +1924,12 @@ msgid "See also :c:member:`PyConfig.exec_prefix`." msgstr "也請見 :c:member:`PyConfig.exec_prefix`" #: ../../c-api/init_config.rst:1240 -#, fuzzy msgid "Python base executable: ``sys._base_executable``." -msgstr ":c:member:`base_executable `" +msgstr "Python 基礎可執行檔:``sys._base_executable``。" #: ../../c-api/init_config.rst:1242 -#, fuzzy msgid "Set by the ``__PYVENV_LAUNCHER__`` environment variable." -msgstr "由 :envvar:`__PYVENV_LAUNCHER__` 環境變數設定。" +msgstr "由 ``__PYVENV_LAUNCHER__`` 環境變數設定。" #: ../../c-api/init_config.rst:1244 msgid "Set from :c:member:`PyConfig.executable` if ``NULL``." @@ -2601,6 +2601,8 @@ msgid "" "If the ``WITH_NEXT_FRAMEWORK`` macro is defined, use ``__PYVENV_LAUNCHER__`` " "environment variable if set." msgstr "" +"如果定義了 ``WITH_NEXT_FRAMEWORK`` 巨集,且已設定 ``__PYVENV_LAUNCHER__`` 環" +"境變數,則使用該環境變數。" #: ../../c-api/init_config.rst:1749 msgid "" @@ -2908,6 +2910,9 @@ msgid "" "order: the last :c:member:`PyConfig.warnoptions` item becomes the first item " "of ``warnings.filters`` which is checked first (highest priority)." msgstr "" +":mod:`warnings` 模組會以相反順序新增 :data:`sys.warnoptions`:最後一個 :c:" +"member:`PyConfig.warnoptions` 項目會成為 ``warnings.filters`` 中第一個被檢查" +"(優先度最高)的項目。" #: ../../c-api/init_config.rst:1986 msgid "" diff --git a/c-api/intro.po b/c-api/intro.po index a031ed85e4..fe3cc6306f 100644 --- a/c-api/intro.po +++ b/c-api/intro.po @@ -773,20 +773,16 @@ msgid "Consider using the C99 standard suffixes ``LL`` and ``LLU`` directly." msgstr "" #: ../../c-api/intro.rst:511 -#, fuzzy msgid "This is an alias to :c:func:`!memcpy`." -msgstr "這現在是 ``va_copy`` 的別名。" +msgstr "此為 :c:func:`!memcpy` 的別名。" #: ../../c-api/intro.rst:513 msgid "Use :c:func:`!memcpy` directly instead." -msgstr "" +msgstr "請直接使用 :c:func:`!memcpy`。" #: ../../c-api/intro.rst:518 -#, fuzzy msgid "This is an alias to the C99-standard ``va_copy`` function." -msgstr "" -"這是 C99 標準 ``va_copy`` 函式的已\\ :term:`軟性棄用 `\\ 別" -"名。" +msgstr "此為 C99 標準 ``va_copy`` 函式的別名。" #: ../../c-api/intro.rst:520 msgid "" @@ -983,15 +979,13 @@ msgstr "" "照 `\\ 就不需要做任何事情。" #: ../../c-api/intro.rst:642 -#, fuzzy msgid "" "Conversely, when a calling function passes in a reference to an object, " "there are two possibilities: the function *steals* a reference to the " "object, or it does not." msgstr "" -"相反地,當呼叫的函式傳入物件的參照時,有兩種可能性:函式有\\ *竊取 (steal)* " -"物件的參照,或者沒有。 *竊取參照*\\ 意味著當你將參照傳遞給函式時,該函式假定" -"它現在擁有該參照,並且你不再對它負責。" +"相反地,當呼叫的函式傳入物件的參照時,有兩種可能性:函式\\ *竊取 (steal)*\\ " +"物件的參照,或者沒有。" #: ../../c-api/intro.rst:646 msgid "" @@ -1000,6 +994,9 @@ msgid "" "can use :c:func:`!Py_DECREF` at its discretion, you (the caller) must not " "use that reference after the call." msgstr "" +"*竊取參照*\\ 意味著當你將參照傳遞給函式時,該函式假定它現在擁有該參照。由於新" +"的擁有者可以自行決定何時呼叫 :c:func:`!Py_DECREF`,你(呼叫者)在呼叫之後就不" +"可以再使用該參照。" #: ../../c-api/intro.rst:655 msgid "" @@ -1695,7 +1692,6 @@ msgstr "" "建置 `。" #: ../../c-api/intro.rst:1076 -#, fuzzy msgid "" "Defining ``Py_TRACE_REFS`` enables reference tracing (see the :option:" "`configure --with-trace-refs option <--with-trace-refs>`). When defined, a " @@ -1704,11 +1700,11 @@ msgid "" "well. Upon exit, all existing references are printed. (In interactive mode " "this happens after every statement run by the interpreter.)" msgstr "" -"定義 :c:macro:`Py_TRACE_REFS` 來啟用參照追蹤(參見\\ :option:`設定 --with-" -"trace-refs 選項 <--with-trace-refs>`)。當有定義時,透過向每個 :c:type:" -"`PyObject` 新增兩個額外欄位來維護有效物件的循環雙向鍊表 (circular doubly " -"linked list)。全體分配也有被追蹤。退出時將印出所有現行參照。(在交互模式下," -"這發生在直譯器運行的每個陳述句之後。)" +"定義 ``Py_TRACE_REFS`` 來啟用參照追蹤(參見\\ :option:`設定 --with-trace-" +"refs 選項 <--with-trace-refs>`)。當有定義時,透過向每個 :c:type:`PyObject` " +"新增兩個額外欄位來維護有效物件的循環雙向鍊表 (circular doubly linked list)。" +"全體分配也有被追蹤。退出時將印出所有現行參照。(在交互模式下,這發生在直譯器" +"運行的每個陳述句之後。)" #: ../../c-api/intro.rst:1083 msgid "" diff --git a/c-api/list.po b/c-api/list.po index b35893c5ba..568544fb18 100644 --- a/c-api/list.po +++ b/c-api/list.po @@ -123,13 +123,13 @@ msgstr "" "出邊界範圍則回傳 ``-1`` 並設定一個 :exc:`IndexError` 例外。" #: ../../c-api/list.rst:105 -#, fuzzy msgid "" "This function \":term:`steals `\" a reference to *item*, even on " "error. On success, it discards a reference to an item already in the list at " "the affected position (unless it was ``NULL``)." msgstr "" -"此函式「竊取」對 *item* 的參照,並丟棄對串列中受影響位置上已存在項目的參照。" +"此函式「:term:`竊取 `」對 *item* 的參照,即使發生錯誤也一樣。成功時," +"它會丟棄串列中受影響位置上已存在項目的參照(除非該項目為 ``NULL``)。" #: ../../c-api/list.rst:113 msgid "" @@ -149,15 +149,14 @@ msgstr "" "查。" #: ../../c-api/list.rst:122 -#, fuzzy msgid "" "This macro \":term:`steals `\" a reference to *item*, and, unlike :c:" "func:`PyList_SetItem`, does *not* discard a reference to any item that is " "being replaced; any reference in *list* at position *i* will be leaked." msgstr "" -"該巨集「竊取」對 *item* 的參照,並且與 :c:func:`PyList_SetItem` 不同的是,它" -"\\ *不會*\\ 丟棄對任意被替換項目的參照;*list* 中位置 *i* 的任何參照都將被洩" -"漏 (leak)。" +"該巨集「:term:`竊取 `」對 *item* 的參照,並且與 :c:func:" +"`PyList_SetItem` 不同的是,它\\ *不會*\\ 丟棄對任意被替換項目的參照;*list* " +"中位置 *i* 的任何參照都將被洩漏 (leak)。" #: ../../c-api/list.rst:129 msgid "" diff --git a/c-api/memory.po b/c-api/memory.po index 7686b4d133..9a26b6bbbe 100644 --- a/c-api/memory.po +++ b/c-api/memory.po @@ -108,6 +108,15 @@ msgid "" "in the previous example, the allocated memory for the I/O buffer completely " "escapes the Python memory manager." msgstr "" +"然而,在大多數情況下,建議從 Python 堆積分配記憶體,這是因為 Python 堆積是由 " +"Python 記憶體管理器所控制的。舉例來說,當直譯器被以 C 撰寫的新物件型別擴充" +"時,就必須這樣做。使用 Python 堆積的另一個理由,是希望能\\ *告知*\\ Python 記" +"憶體管理器該擴充模組的記憶體需求。即使所請求的記憶體僅用於內部、高度特定的用" +"途,將所有記憶體請求都委託給 Python 記憶體管理器,也能讓直譯器對其整體的記憶" +"體使用狀況有更準確的掌握。因此,在某些情況下,Python 記憶體管理器可能會(或可" +"能不會)觸發適當的動作,例如垃圾回收、記憶體壓縮或其他預防性程序。請注意,如" +"同前面範例所示,若使用 C 函式庫的分配器,配置給 I/O 緩衝區的記憶體會完全逃脫 " +"Python 記憶體管理器的掌控。" #: ../../c-api/memory.rst:88 msgid "" @@ -226,6 +235,9 @@ msgid "" "of type :c:expr:`void*` to the allocated memory, or ``NULL`` if the request " "fails. The memory is initialized to zeros." msgstr "" +"分配 *nelem* 個元素,每個元素大小為 *elsize* 個位元組,並回傳一個型別為 :c:" +"expr:`void*` 的指標指向所分配的記憶體;如果請求失敗則回傳 ``NULL``。這塊記憶" +"體會被初始化為零。" #: ../../c-api/memory.rst:168 msgid "" diff --git a/c-api/module.po b/c-api/module.po index cb4b083be9..3170cd7757 100644 --- a/c-api/module.po +++ b/c-api/module.po @@ -651,6 +651,9 @@ msgid "" "function that returns a new reference without bothering to check its result " "or even saving it to a variable." msgstr "" +"類似於 :c:func:`PyModule_AddObjectRef`,但會「:term:`竊取 `」對 " +"*value* 的參照(即使發生錯誤也一樣)。它可以搭配某個回傳新參照之函式的結果來" +"呼叫,而不需要費心檢查其結果,甚至不需要將其儲存到變數中。" #: ../../c-api/module.rst:569 msgid "" @@ -663,13 +666,12 @@ msgstr "" "}" #: ../../c-api/module.rst:578 -#, fuzzy msgid "" "Similar to :c:func:`PyModule_AddObjectRef`, but :term:`steals ` a " "reference to *value* on success (if it returns ``0``)." msgstr "" -"類似於 :c:func:`PyModule_AddObjectRef`,但在成功時(如果回傳 ``0``)會偷走對 " -"*value* 的參照。" +"類似於 :c:func:`PyModule_AddObjectRef`,但在成功時(如果回傳 ``0``)會\\ :" +"term:`竊取 `\\ 對 *value* 的參照。" #: ../../c-api/module.rst:581 msgid "" diff --git a/c-api/perfmaps.po b/c-api/perfmaps.po index 3484611fcd..c9d2011071 100644 --- a/c-api/perfmaps.po +++ b/c-api/perfmaps.po @@ -119,6 +119,7 @@ msgid "" "Open the ``/tmp/perf-$pid.map`` file and append the content of " "*parent_filename* to it." msgstr "" +"打開 ``/tmp/perf-$pid.map`` 檔案,並將 *parent_filename* 的內容附加到其中。" #: ../../c-api/perfmaps.rst:57 msgid "" @@ -126,59 +127,67 @@ msgid "" "platforms that support perf maps (currently only Linux). On other platforms, " "it does nothing." msgstr "" +"此函式在所有平台上都可用,但只有在支援 perf map 的平台(目前僅限 Linux)上才" +"會產生輸出。在其他平台上,它不會執行任何操作。" #: ../../c-api/perfmaps.rst:64 msgid "Compile the given code object using the current perf trampoline." -msgstr "" +msgstr "使用目前的 perf trampoline 編譯給定的程式碼物件。" #: ../../c-api/perfmaps.rst:66 msgid "" "The \"current\" trampoline is the one set by the runtime or the most recent :" "c:func:`PyUnstable_PerfTrampoline_SetPersistAfterFork` call." msgstr "" +"「目前」的 trampoline,是指由 runtime 或最近一次呼叫\\ :c:func:" +"`PyUnstable_PerfTrampoline_SetPersistAfterFork` 所設定的那一個。" #: ../../c-api/perfmaps.rst:69 msgid "" "If no trampoline is set, falls back to normal compilation (no perf map " "entry)." -msgstr "" +msgstr "如果沒有設定 trampoline,則退回正常編譯(不產生 perf map 條目)。" #: ../../c-api/perfmaps.rst:0 msgid "Parameters" -msgstr "" +msgstr "參數" #: ../../c-api/perfmaps.rst:71 msgid "The code object to compile." -msgstr "" +msgstr "要編譯的程式碼物件。" #: ../../c-api/perfmaps.rst:0 msgid "Returns" -msgstr "" +msgstr "回傳值" #: ../../c-api/perfmaps.rst:72 ../../c-api/perfmaps.rst:88 msgid "0 on success, -1 on failure." -msgstr "" +msgstr "成功時回傳 0,失敗時回傳 -1。" #: ../../c-api/perfmaps.rst:78 msgid "Set whether the perf trampoline should persist after a fork." -msgstr "" +msgstr "設定 perf trampoline 在 fork 之後是否應該持續存在。" #: ../../c-api/perfmaps.rst:80 msgid "" "If ``enable`` is true (non-zero): perf map file remains open/valid post-" "fork. Child process inherits all existing perf map entries." msgstr "" +"如果 ``enable`` 為 true(非零):perf map 檔案在 fork 後仍保持開啟/有效,子" +"行程會繼承所有既有的 perf map 條目。" #: ../../c-api/perfmaps.rst:82 msgid "" "If ``enable`` is false (zero): perf map closes post-fork. Child process gets " "empty perf map." msgstr "" +"如果 ``enable`` 為 false(零):perf map 會在 fork 後關閉,子行程會得到空的 " +"perf map。" #: ../../c-api/perfmaps.rst:85 msgid "Default: false (clears on fork)." -msgstr "" +msgstr "預設值:false(在 fork 時清除)。" #: ../../c-api/perfmaps.rst:87 msgid "1 to enable, 0 to disable." -msgstr "" +msgstr "1 表示啟用,0 表示停用。" diff --git a/c-api/sequence.po b/c-api/sequence.po index 78f72a8cd6..2888d445b2 100644 --- a/c-api/sequence.po +++ b/c-api/sequence.po @@ -82,6 +82,9 @@ msgid "" "of the Python statement ``o[i] = v``. This function *does not* \":term:" "`steal`\" a reference to *v*." msgstr "" +"將物件 *v* 指定給 *o* 的第 *i* 個元素。失敗時引發例外並回傳 ``-1``;成功時回" +"傳 ``0``。這相當於 Python 陳述式 ``o[i] = v``。此函式\\ *不會*\\ 「:term:`竊" +"取 `」對 *v* 的參照。" #: ../../c-api/sequence.rst:72 msgid "" diff --git a/c-api/set.po b/c-api/set.po index 3b1511a472..2669ebacad 100644 --- a/c-api/set.po +++ b/c-api/set.po @@ -224,13 +224,10 @@ msgid "Deprecated API" msgstr "已棄用的 API" #: ../../c-api/set.rst:207 -#, fuzzy msgid "" "A constant representing the size of an internal preallocated table inside :c:" "type:`PySetObject` instances." -msgstr "" -"一個被\\ :term:`軟性棄用 `\\ 的常數,代表 :c:type:" -"`PySetObject` 實例內部預分配表格的大小。" +msgstr "一個代表 :c:type:`PySetObject` 實例內部預分配表格大小的常數。" #: ../../c-api/set.rst:210 msgid "" diff --git a/c-api/structures.po b/c-api/structures.po index 00e204a1b0..335084f898 100644 --- a/c-api/structures.po +++ b/c-api/structures.po @@ -530,6 +530,8 @@ msgid "" "an instance of the type. This is used to create *class methods*, similar to " "what is created when using the :deco:`classmethod` built-in decorator." msgstr "" +"此方法將會以型別物件作為第一個參數傳入,而非該型別的實例。這用於建立類別方" +"法,類似於使用內建裝飾器 :deco:`classmethod` 時所建立的效果。" #: ../../c-api/structures.rst:430 msgid "" @@ -537,6 +539,8 @@ msgid "" "instance of the type. This is used to create *static methods*, similar to " "what is created when using the :deco:`staticmethod` built-in decorator." msgstr "" +"此方法將會以 ``NULL`` 作為第一個參數傳入,而非該型別的實例。這用於建立靜態方" +"法,類似於使用內建裝飾器 :deco:`staticmethod` 時所建立的效果。" #: ../../c-api/structures.rst:434 msgid "" diff --git a/c-api/threads.po b/c-api/threads.po index 13f8ab939f..a2db9f46c8 100644 --- a/c-api/threads.po +++ b/c-api/threads.po @@ -925,6 +925,12 @@ msgid "" "isn't found. If *exc* is ``NULL``, the pending exception (if any) for the " "thread is cleared. This raises no exceptions." msgstr "" +"非同步地在執行緒中引發例外。*id* 引數為目標執行緒的執行緒 id;*exc* 為要引發" +"的例外物件。此函式不會\\ :term:`竊取 `\\ 任何對 *exc* 的參照。為了防止" +"不當誤用,你必須自行編寫 C 擴充來呼叫此函式。呼叫時必須具有\\ :term:`已附加的" +"執行緒狀態 `\\ 。回傳被修改的執行緒狀態數量;通常為" +"一,但若找不到該執行緒 id 則為零。如果 *exc* 為 ``NULL``,則會清除該執行緒的" +"待處理例外(如果有的話)。此函式不會引發任何例外。" #: ../../c-api/threads.rst:750 msgid "" diff --git a/c-api/tuple.po b/c-api/tuple.po index 18e5a17884..59be2fc240 100644 --- a/c-api/tuple.po +++ b/c-api/tuple.po @@ -128,12 +128,13 @@ msgstr "" "*pos* 超出邊界則回傳 ``-1``,並設定 :exc:`IndexError` 例外。" #: ../../c-api/tuple.rst:93 -#, fuzzy msgid "" "This function \":term:`steals `\" a reference to *o* and discards a " "reference to an item already in the tuple at the affected position (unless " "it was NULL)." -msgstr "此函式 \"竊取\" 對 *o* 的參照,並丟棄對元組中受影響位置的項目的參照。" +msgstr "" +"此函式「:term:`竊取 `」對 *o* 的參照,並丟棄元組中該受影響位置上已存在" +"項目的參照(除非該參照為 NULL)。" #: ../../c-api/tuple.rst:100 msgid "" @@ -153,14 +154,14 @@ msgstr "" "with-assertions>` 建置,則會進行作為斷言(asserting)的邊界檢查。" #: ../../c-api/tuple.rst:108 -#, fuzzy msgid "" "This function \":term:`steals `\" a reference to *o*, and, unlike :c:" "func:`PyTuple_SetItem`, does *not* discard a reference to any item that is " "being replaced; any reference in the tuple at position *pos* will be leaked." msgstr "" -"此函式 \"竊取\" 對 *o* 的參照,且與 :c:func:`PyTuple_SetItem` 不同的是,此函" -"式並 *不* 丟棄任何被替代項目的參照;元組中 *pos* 位置的所有參照皆會被洩漏。" +"此函式「:term:`竊取 `」對 *o* 的參照,且與 :c:func:`PyTuple_SetItem` " +"不同的是,此函式並\\ *不*\\ 丟棄任何被替換項目的參照;元組中 *pos* 位置的所有" +"參照皆會被洩漏。" #: ../../c-api/tuple.rst:115 msgid "" @@ -319,9 +320,8 @@ msgstr "" "`PyTuple_SET_ITEM` 類似,此函式僅套用於填充全新實例。" #: ../../c-api/tuple.rst:248 -#, fuzzy msgid "This function \":term:`steals `\" a reference to *o*." -msgstr "此函式 \"竊取\" *o* 的參照。" +msgstr "此函式「:term:`竊取 `」對 *o* 的參照。" #: ../../c-api/tuple.rst:253 msgid "Alias to :c:func:`PyStructSequence_SetItem`." diff --git a/c-api/type.po b/c-api/type.po index 968d140b99..a42030740f 100644 --- a/c-api/type.po +++ b/c-api/type.po @@ -614,7 +614,7 @@ msgstr "" msgid "" "The base is not variable-sized (its :c:member:`~PyTypeObject.tp_itemsize` is " "zero)." -msgstr "" +msgstr "基底並非大小可變的(其 :c:member:`~PyTypeObject.tp_itemsize` 為零)。" #: ../../c-api/type.rst:555 msgid "" diff --git a/c-api/typeobj.po b/c-api/typeobj.po index 6645ee2b96..422e03292c 100644 --- a/c-api/typeobj.po +++ b/c-api/typeobj.po @@ -2547,6 +2547,8 @@ msgid "" "This macro does nothing. Historically, this would indicate that the :c:" "member:`~PyTypeObject.tp_version_tag` field was available and initialized." msgstr "" +"此巨集不執行任何操作。過去,這曾用於表示 :c:member:`~PyTypeObject." +"tp_version_tag` 欄位可用且已初始化。" #: ../../c-api/typeobj.rst:1499 msgid "" @@ -3145,6 +3147,9 @@ msgid "" "When another error occurs, it must return ``NULL`` too. The presence of " "``tp_iternext`` signals that the instances of this type are iterators." msgstr "" +"當疊代器已\\ :term:`耗盡 `\\ 時,``tp_iternext`` 函式必須回傳 " +"``NULL``;是否設定 :exc:`StopIteration` 例外皆可。當發生其他錯誤時,也必須回" +"傳 ``NULL``。``tp_iternext`` 的存在表示該型別的實例是疊代器。" #: ../../c-api/typeobj.rst:1937 msgid "" @@ -4288,6 +4293,8 @@ msgid "" "Check if the request can be met. If not, raise :exc:`BufferError`, set " "``view->obj`` to ``NULL`` and return ``-1``." msgstr "" +"檢查該請求是否能夠被滿足。如果不能,則引發 :exc:`BufferError`,將 ``view-" +">obj`` 設為 ``NULL`` 並回傳 ``-1``。" #: ../../c-api/typeobj.rst:3053 msgid "Fill in the requested fields." @@ -4299,7 +4306,7 @@ msgstr "" #: ../../c-api/typeobj.rst:3057 msgid "Set ``view->obj`` to *exporter* and increment ``view->obj``." -msgstr "" +msgstr "將 ``view->obj`` 設為 *exporter*,並遞增 ``view->obj``。" #: ../../c-api/typeobj.rst:3059 msgid "Return ``0``." @@ -4351,12 +4358,16 @@ msgid "" "Re-export: Each member of the tree acts as the exporting object and sets " "``view->obj`` to a new reference to itself." msgstr "" +"重新匯出:樹狀結構中的每個成員都作為匯出物件,並將 ``view->obj`` 設為指向自身" +"的新參照。" #: ../../c-api/typeobj.rst:3085 msgid "" "Redirect: The buffer request is redirected to the root object of the tree. " "Here, ``view->obj`` will be a new reference to the root object." msgstr "" +"重新導向:緩衝區請求會被重新導向至樹狀結構的根物件。在這種情況下,``view-" +">obj`` 將會是指向該根物件的新參照。" #: ../../c-api/typeobj.rst:3089 msgid "" @@ -4421,6 +4432,8 @@ msgid "" "the final release may race with concurrent releases from other threads and " "deallocation must only happen once." msgstr "" +"當計數器歸零時,資源的清理必須以原子化的方式完成,因為最後一次釋放可能會與其" +"他執行緒的並行釋放產生競爭,且解除配置的動作只能發生一次。" #: ../../c-api/typeobj.rst:3134 msgid "" @@ -4436,6 +4449,8 @@ msgid "" "automatically in :c:func:`PyBuffer_Release` (this scheme is useful for " "breaking reference cycles)." msgstr "" +"此函式絕不能遞減 ``view->obj``,因為這會由 :c:func:`PyBuffer_Release` 自動完" +"成(此機制有助於打破循環參照)。" #: ../../c-api/typeobj.rst:3145 msgid "" diff --git a/c-api/unicode.po b/c-api/unicode.po index 3efbb868f2..8566d25ee7 100644 --- a/c-api/unicode.po +++ b/c-api/unicode.po @@ -925,6 +925,9 @@ msgid "" "term:`strong reference` to a Unicode object; :c:func:`!PyUnicode_Append` " "releases (\":term:`steals `\") this reference." msgstr "" +"將字串 *right* 附加到 *p_left* 的結尾。*p_left* 必須指向一個 Unicode 物件的" +"\\ :term:`強參照 `;:c:func:`!PyUnicode_Append` 會釋放(「:" +"term:`竊取 `」)此參照。" #: ../../c-api/unicode.rst:669 msgid "On error, set *\\*p_left* to ``NULL`` and set an exception." diff --git a/c-api/veryhigh.po b/c-api/veryhigh.po index dfa9b28bdf..2c8e8c752b 100644 --- a/c-api/veryhigh.po +++ b/c-api/veryhigh.po @@ -388,9 +388,8 @@ msgid "" msgstr "" #: ../../c-api/veryhigh.rst:347 -#, fuzzy msgid "Low-level flags" -msgstr "編譯器旗標。" +msgstr "低階旗標" #: ../../c-api/veryhigh.rst:348 msgid "" @@ -399,6 +398,8 @@ msgid "" "reason to use them. They are considered implementation details and may " "change at any time." msgstr "" +"以下的旗標和遮罩僅滿足標準函式庫和互動式直譯器的少數特定需求,標準函式庫以外" +"的程式碼很少有理由使用它們。它們被視為實作細節,可能隨時變更。" #: ../../c-api/veryhigh.rst:355 msgid "" @@ -406,6 +407,8 @@ msgid "" "module. Do not use it; its behavior is unsupported and may change without " "warning." msgstr "" +"此旗標是編譯器與 :mod:`codeop` 模組之間的私有介面,請勿使用;其行為不受支援," +"且可能在沒有警告的情況下變更。" #: ../../c-api/veryhigh.rst:359 msgid "" @@ -418,6 +421,12 @@ msgid "" "with a real syntax error, so that interactive interpreters know when to " "prompt for another line instead of reporting an error." msgstr "" +"設定此旗標後,當編譯因原始文字在預期需要更多輸入之處結束而失敗時(例如在縮排" +"區塊中間或未結束的字串字面值中),所引發的錯誤會是未有文件記載的 " +"``_IncompleteInputError``,它是 :exc:`SyntaxError` 的子類別。:mod:`codeop` 模" +"組會設定此旗標,並搭配 :c:macro:`PyCF_DONT_IMPLY_DEDENT`,以區分不完整的輸入" +"與帶有真正語法錯誤的輸入,讓互動式直譯器知道何時該提示輸入下一行,而不是回報" +"錯誤。" #: ../../c-api/veryhigh.rst:373 msgid "" @@ -427,6 +436,9 @@ msgid "" "the source ends with a newline; otherwise, compilation fails with a :exc:" "`SyntaxError`:" msgstr "" +"依預設,使用 :c:var:`Py_single_input` 起始符號進行編譯時,抵達原始文字結尾會" +"隱式關閉所有開啟的縮排區塊。設定此旗標後,只有當原始碼的最後一行以換行符號結" +"尾時,開啟的區塊才會被關閉;否則編譯會失敗並引發 :exc:`SyntaxError`:" #: ../../c-api/veryhigh.rst:379 msgid "" @@ -445,6 +457,20 @@ msgid "" "flags.cf_flags = PyCF_DONT_IMPLY_DEDENT;\n" "Py_CompileStringFlags(source, \"\", Py_single_input, &flags);" msgstr "" +"PyCompilerFlags flags = {\n" +" .cf_flags = 0,\n" +" .cf_feature_version = PY_MINOR_VERSION,\n" +"};\n" +"const char *source = \"if a:\\n pass\";\n" +"\n" +"/* 「if」區塊被隱式關閉;\n" +" 這會回傳一個程式碼物件: */\n" +"Py_CompileStringFlags(source, \"\", Py_single_input, &flags);\n" +"\n" +"/* 加上此旗標後,這會因為 SyntaxError 而失敗,\n" +" 因為最後一行沒有以換行符號結尾: */\n" +"flags.cf_flags = PyCF_DONT_IMPLY_DEDENT;\n" +"Py_CompileStringFlags(source, \"\", Py_single_input, &flags);" #: ../../c-api/veryhigh.rst:396 msgid "" @@ -453,12 +479,16 @@ msgid "" "does not yet end with a newline, so it fails to compile and the user is " "prompted for another line." msgstr "" +":mod:`codeop` 模組使用此旗標來偵測不完整的互動式輸入。當使用者仍在縮排區塊內" +"輸入時,原始碼尚未以換行符號結尾,因此編譯會失敗,並提示使用者輸入下一行。" #: ../../c-api/veryhigh.rst:403 msgid "" "Read the source text as UTF-8, ignoring its :pep:`263` encoding declaration " "(\"coding cookie\"), if any:" msgstr "" +"將原始文字以 UTF-8 讀取,忽略其 :pep:`263` 編碼宣告(「coding cookie」,如果" +"有的話):" #: ../../c-api/veryhigh.rst:406 msgid "" @@ -477,6 +507,20 @@ msgid "" "flags.cf_flags = PyCF_IGNORE_COOKIE;\n" "Py_CompileStringFlags(source, \"\", Py_file_input, &flags);" msgstr "" +"PyCompilerFlags flags = {\n" +" .cf_flags = 0,\n" +" .cf_feature_version = PY_MINOR_VERSION,\n" +"};\n" +"const char *source = \"# coding: latin-1\\ns = '\\xe9'\\n\";\n" +"\n" +"/* coding cookie 被遵循:位元組 0xE9 被解碼為\n" +" Latin-1,這會回傳一個將 s 設為 \"é\" 的程式碼物件: */\n" +"Py_CompileStringFlags(source, \"\", Py_file_input, &flags);\n" +"\n" +"/* 加上此旗標後,cookie 會被忽略,導致編譯失敗\n" +" 並出現 SyntaxError,因為 0xE9 不是有效的 UTF-8: */\n" +"flags.cf_flags = PyCF_IGNORE_COOKIE;\n" +"Py_CompileStringFlags(source, \"\", Py_file_input, &flags);" #: ../../c-api/veryhigh.rst:423 msgid "" @@ -484,6 +528,8 @@ msgid "" "this flag when the source is a :class:`str` object, because they pass the " "text to the parser encoded as UTF-8." msgstr "" +":func:`compile`、:func:`eval` 和 :func:`exec` 這幾個內建函式,會在原始碼是 :" +"class:`str` 物件時設定此旗標,因為它們會將文字以 UTF-8 編碼傳遞給剖析器。" #: ../../c-api/veryhigh.rst:429 msgid "" @@ -491,6 +537,8 @@ msgid "" "func:`eval` and :func:`exec` built-in functions set this flag, but it " "currently has no effect." msgstr "" +"將原始文字標記為已知採用 UTF-8 編碼。:func:`compile`、:func:`eval` 和 :func:" +"`exec` 這幾個內建函式會設定此旗標,但目前沒有任何效果。" #: ../../c-api/veryhigh.rst:433 msgid "" @@ -502,7 +550,7 @@ msgstr "" #: ../../c-api/veryhigh.rst:438 msgid "The following masks combine several flags:" -msgstr "" +msgstr "以下的遮罩結合了數個旗標:" #: ../../c-api/veryhigh.rst:442 msgid "" @@ -512,17 +560,24 @@ msgid "" "__future__ import`` statement, the flag for the imported feature is added to " "*flags*, so that code executed later in the same context inherits it." msgstr "" +"所有 ``CO_FUTURE`` 旗標的位元遮罩(請參閱 :ref:`c_codeobject_flags`),這些旗" +"標用來選擇通常由 :ref:`future 陳述式 `\\ 啟用的功能。當使用 " +"``PyCompilerFlags *flags`` 引數編譯的程式碼包含 ``from __future__ import`` 陳" +"述式時,該匯入功能所對應的旗標會被加入 *flags* 中,讓稍後在同一情境中執行的程" +"式碼繼承它。" #: ../../c-api/veryhigh.rst:452 msgid "" "Do not use this mask in new code. It is kept only so that old code passing " "its flags to :func:`compile` keeps working." msgstr "" +"請勿在新程式碼中使用此遮罩,保留它只是為了讓傳遞其旗標給 :func:`compile` 的舊" +"有程式碼能繼續運作。" #: ../../c-api/veryhigh.rst:455 msgid "" "Bitmask of flags for obsolete future features that no longer have any effect." -msgstr "" +msgstr "已過時且不再有任何作用的 future 功能旗標之位元遮罩。" #: ../../c-api/veryhigh.rst:460 msgid "" @@ -530,6 +585,9 @@ msgid "" "as :c:macro:`PyCF_ONLY_AST`. The :func:`compile` built-in function uses this " "mask to validate its *flags* argument." msgstr "" +"所有會改變原始碼編譯方式的 ``PyCF`` 旗標之位元遮罩,例如 :c:macro:" +"`PyCF_ONLY_AST`。:func:`compile` 這個內建函式使用此遮罩來驗證其 *flags* 引" +"數。" #: ../../c-api/veryhigh.rst:469 msgid "Available start symbols" diff --git a/c-api/weakref.po b/c-api/weakref.po index f20eee57aa..ab0d213cf6 100644 --- a/c-api/weakref.po +++ b/c-api/weakref.po @@ -64,6 +64,11 @@ msgid "" "weakly referenceable object, this will raise :exc:`TypeError` and return " "``NULL``." msgstr "" +"回傳物件 *ob* 的弱參照物件。這總是會回傳一個新參照,但不保證會建立一個新物" +"件;也可能會回傳一個已存在的參照物件。第二個參數 *callback* 可以是一個可呼叫" +"物件,會在 *ob* 被垃圾回收時收到通知;它應該接受一個參數,也就是該弱參照物件" +"本身。*callback* 也可以是 ``None`` 或 ``NULL``。如果 *ob* 不是可被弱參照的物" +"件,則會引發 :exc:`TypeError` 並回傳 ``NULL``。" #: ../../c-api/weakref.rst:49 ../../c-api/weakref.rst:65 msgid "" @@ -82,6 +87,11 @@ msgid "" "*ob* weakly referenceable object, this will raise :exc:`TypeError` and " "return ``NULL``." msgstr "" +"回傳物件 *ob* 的弱參照代理物件。這總是會回傳一個新參照,但不保證會建立一個新" +"物件;也可能會回傳一個已存在的代理物件。第二個參數 *callback* 可以是一個可呼" +"叫物件,會在 *ob* 被垃圾回收時收到通知;它應該接受一個參數,也就是該弱參照物" +"件本身。*callback* 也可以是 ``None`` 或 ``NULL``。如果 *ob* 不是可被弱參照的" +"物件,則會引發 :exc:`TypeError` 並回傳 ``NULL``。" #: ../../c-api/weakref.rst:71 msgid "" diff --git a/deprecations/index.po b/deprecations/index.po index bb493b9027..56f11683a4 100644 --- a/deprecations/index.po +++ b/deprecations/index.po @@ -193,13 +193,12 @@ msgstr "" "pass`` 或 ``TD = TypedDict(\"TD\", {})`` 來建立具有零個欄位的 TypedDict。" #: ../../deprecations/pending-removal-in-3.15.rst:85 -#, fuzzy msgid "" "The :deco:`typing.no_type_check_decorator` decorator function has been " "deprecated since Python 3.13. After eight years in the :mod:`typing` module, " "it has yet to be supported by any major type checker." msgstr "" -"自 Python 3.13 起,:func:`typing.no_type_check_decorator` 裝飾器函式已被棄" +"自 Python 3.13 起,:deco:`typing.no_type_check_decorator` 裝飾器函式已被棄" "用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的支" "援。" diff --git a/deprecations/pending-removal-in-3.15.po b/deprecations/pending-removal-in-3.15.po index 5bd49d9078..b02f76ac4d 100644 --- a/deprecations/pending-removal-in-3.15.po +++ b/deprecations/pending-removal-in-3.15.po @@ -183,13 +183,12 @@ msgstr "" "pass`` 或 ``TD = TypedDict(\"TD\", {})`` 來建立具有零個欄位的 TypedDict。" #: ../../deprecations/pending-removal-in-3.15.rst:85 -#, fuzzy msgid "" "The :deco:`typing.no_type_check_decorator` decorator function has been " "deprecated since Python 3.13. After eight years in the :mod:`typing` module, " "it has yet to be supported by any major type checker." msgstr "" -"自 Python 3.13 起,:func:`typing.no_type_check_decorator` 裝飾器函式已被棄" +"自 Python 3.13 起,:deco:`typing.no_type_check_decorator` 裝飾器函式已被棄" "用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的支" "援。" diff --git a/extending/extending.po b/extending/extending.po index c8a702f9f8..798f03de05 100644 --- a/extending/extending.po +++ b/extending/extending.po @@ -1138,7 +1138,6 @@ msgstr "" "機制;其實作將需要從 C 回呼中呼叫 Python 回呼函式。其他用途也是可以想像的。" #: ../../extending/extending.rst:547 -#, fuzzy msgid "" "Fortunately, the Python interpreter is easily called recursively, and there " "is a standard interface to call a Python function. (If you're interested in " @@ -1146,9 +1145,8 @@ msgid "" "`veryhigh`.)" msgstr "" "幸運的是,Python 直譯器可以很容易地被遞迴呼叫,並且有一個標準介面可以呼叫 " -"Python 函式。(我不會深入討論如何以特定字串作為輸入來呼叫 Python 剖析器 --- " -"如果你有興趣,可以查看 Python 原始碼中 :file:`Modules/main.c` 裡 :option:`-" -"c` 命令列選項的實作。)" +"Python 函式。(如果你對於如何以特定字串作為輸入來呼叫 Python 剖析器感興趣,請" +"參閱\\ :ref:`veryhigh`。)" #: ../../extending/extending.rst:551 msgid "" @@ -1893,7 +1891,6 @@ msgstr "" "歸零時,表示該物件的最後一個參照已被刪除,物件便被釋放。" #: ../../extending/extending.rst:937 -#, fuzzy msgid "" "An alternative strategy is called :dfn:`automatic garbage collection`. " "(Sometimes, reference counting is also referred to as a garbage collection " @@ -1909,10 +1906,10 @@ msgid "" "with reference counts." msgstr "" "另一種替代策略稱為\\ :dfn:`自動垃圾回收 (automatic garbage collection)`。(有" -"時,參照計數也被稱為一種垃圾回收策略,因此我使用「自動」來區分兩者。)自動垃" -"圾回收的最大優點是使用者不需要明確地呼叫 :c:func:`free`。(另一個聲稱的優點是" -"速度或記憶體使用量的改善 --- 但這並非確定的事實。)缺點是對於 C 語言而言,並" -"沒有真正可移植的自動垃圾回收器,而參照計數可以被可移植地實作(只要 :c:func:" +"時,參照計數也被稱為一種垃圾回收策略,因此才用「自動」來區分兩者。)自動垃圾" +"回收的最大優點是使用者不需要明確地呼叫 :c:func:`free`。(另一個聲稱的優點是速" +"度或記憶體使用量的改善 --- 但這並非確定的事實。)缺點是對於 C 語言而言,並沒" +"有真正可移植的自動垃圾回收器,而參照計數可以被可移植地實作(只要 :c:func:" "`malloc` 和 :c:func:`free` 函式可用 --- 這是 C 標準所保證的)。也許有一天會有" "足夠可移植的 C 自動垃圾回收器可用。在那之前,我們只能與參照計數共存。" @@ -2815,7 +2812,6 @@ msgstr "" "式的基本結構都是相同的,所以只需要學習一次。" #: ../../extending/extending.rst:1404 -#, fuzzy msgid "" "Finally it should be mentioned that Capsules offer additional functionality, " "which is especially useful for memory allocation and deallocation of the " @@ -2824,10 +2820,10 @@ msgid "" "Capsules (files :file:`Include/pycapsule.h` and :file:`Objects/capsule.c` in " "the Python source code distribution)." msgstr "" -"最後應該提到的是,Capsule 提供了額外的功能,這對於 Capsule 中儲存的指標的記憶" -"體配置和釋放特別有用。詳細資訊在 Python/C API 參考手冊的 :ref:`capsules` 章節" -"以及 Capsule 的實作中有描述(Python 原始碼發行版中的 :file:`Include/" -"pycapsule.h` 和 :file:`Objects/pycapsule.c` 檔案)。" +"最後應該提到的是,Capsule 提供了額外的功能,這對於 Capsule 中儲存之指標的記憶" +"體配置和釋放特別有用。詳細資訊在 Python/C API 參考手冊的 :ref:`capsules` 章" +"節,以及 Capsule 的實作中有描述(Python 原始碼發行版中的 :file:`Include/" +"pycapsule.h` 和 :file:`Objects/capsule.c` 檔案)。" #: ../../extending/extending.rst:1412 msgid "Footnotes" diff --git a/extending/index.po b/extending/index.po index eb37b6e1f3..6a8adc5821 100644 --- a/extending/index.po +++ b/extending/index.po @@ -40,7 +40,6 @@ msgstr "" "以動態地(在執行環境)被載入到直譯器中,前提是底層作業系統有支援這個功能。" #: ../../extending/index.rst:15 -#, fuzzy msgid "" "This document assumes basic knowledge about C and Python. For an informal " "introduction to Python, see :ref:`tutorial-index`. :ref:`reference-index` " @@ -49,10 +48,11 @@ msgid "" "documents the modules (both built-in and written in Python) that give the " "language its wide application range." msgstr "" -"這份說明文件假設你具備 Python 的基礎知識。關於此語言的非正式介紹,請參閱 :" -"ref:`tutorial-index`。:ref:`reference-index`\\ 給予此語言更為正式的定義。:" -"ref:`library-index` 記錄了賦予此語言廣泛應用範圍的物件型別、函式與(內建的和" -"以 Python 編寫的)模組。" +"這份說明文件假設你具備 C 和 Python 的基礎知識。關於 Python 的非正式介紹,請參" +"閱 :ref:`tutorial-index`。:ref:`reference-index`\\ 給予此語言更為正式的定" +"義。:ref:`builtins-index`\\ 記錄了內建函式與物件型別,而 :ref:`library-" +"index`\\ 則記錄了賦予此語言廣泛應用範圍的模組(包含內建模組與以 Python 撰寫的" +"模組)。" #: ../../extending/index.rst:22 msgid "" diff --git a/faq/design.po b/faq/design.po index 5416fc0beb..c9528cec1a 100644 --- a/faq/design.po +++ b/faq/design.po @@ -523,6 +523,11 @@ msgid "" "statements. An older alternative is a sequence of ``if... elif... elif... " "else``." msgstr "" +"一般來說,結構化的 switch 陳述式會在運算式具有特定值或一組值時執行對應的程式" +"碼區塊。自 Python 3.10 起,你可以輕鬆地用 ``match ... case`` 陳述式來比對字面" +"值,或是命名空間中的常數。關於 :keyword:`match` 陳述式的更多資訊,請參閱\\ :" +"ref:`規格說明 `\\ 和\\ :ref:`教學 `\\ 。較舊的替代方式是使" +"用一連串的 ``if... elif... elif... else``。" #: ../../faq/design.rst:270 msgid "" @@ -878,7 +883,7 @@ msgstr "" #: ../../faq/design.rst:448 msgid "" "See :ref:`time-complexity` for the costs of the various list operations." -msgstr "" +msgstr "各種串列操作的成本請參閱\\ :ref:`time-complexity`\\ 。" #: ../../faq/design.rst:454 msgid "How are dictionaries implemented in CPython?" @@ -916,7 +921,7 @@ msgstr "" msgid "" "See :ref:`time-complexity` for the costs of the various dictionary " "operations." -msgstr "" +msgstr "各種字典操作的成本請參閱\\ :ref:`time-complexity`\\ 。" #: ../../faq/design.rst:473 msgid "Why must dictionary keys be immutable?" diff --git a/faq/library.po b/faq/library.po index a69d64d728..d7dd1362bf 100644 --- a/faq/library.po +++ b/faq/library.po @@ -42,36 +42,35 @@ msgid "" "relevant standard library module. (Eventually you'll learn what's in the " "standard library and will be able to skip this step.)" msgstr "" -"查看\\ :ref:`函式庫參照 `\\ 以了解是否有相關的標準函式庫模組。 " -"(當你熟悉標準函式庫中的內容後就可以能跳過這一步。)" +"查看\\ :ref:`函式庫參照 `\\ 以了解是否有相關的標準函式庫模" +"組。 (當你熟悉標準函式庫中的內容後就可以能跳過這一步。)" #: ../../faq/library.rst:21 msgid "" -"For third-party packages, search the `Python Package Index `_ or try `Google `_ or another web search " +"For third-party packages, search the `Python Package Index `_ or try `Google `_ or another web search " "engine. Searching for \"Python\" plus a keyword or two for your topic of " "interest will usually find something helpful." msgstr "" -"對於第三方套件,搜尋 `Python 套件索引 `_\\ 或嘗試使用 `Google " -"`_ 或其他網路搜尋引擎。搜尋 \"Python\" 加上你感興趣主題的一" -"兩個關鍵字,通常能夠找到有用的東西。" +"對於第三方套件,搜尋 `Python 套件索引 `_\\ 或嘗試使用 " +"`Google `_ 或其他網路搜尋引擎。搜尋 \"Python\" 加上你" +"感興趣主題的一兩個關鍵字,通常能夠找到有用的東西。" #: ../../faq/library.rst:28 msgid "Where is the math.py (socket.py, regex.py, etc.) source file?" msgstr "哪裡可以找到 math.py (socket.py, regex.py, 等...) 來源檔案?" #: ../../faq/library.rst:30 -#, fuzzy msgid "" "If you can't find a source file for a module it may be a built-in or " "dynamically loaded module implemented in C, C++ or other compiled language. " -"In this case you may not have the source file or it may be something " -"like :file:`mathmodule.c`, somewhere in a C source directory (not on the " -"Python Path)." +"In this case you may not have the source file or it may be something like :" +"file:`mathmodule.c`, somewhere in a C source directory (not on the Python " +"Path)." msgstr "" -"如果找不到模組的源檔案,它可能是用 C、C++ 或其他編譯語言實作的內置或動態載入" -"的模組。在這種情況下,你可能沒有源檔案,或者它可能類似" -"於 :file:`mathmodule.c`,位於 C 源目錄中(不在 Python 路徑中)。" +"如果找不到模組的原始檔案,它可能是用 C、C++ 或其他編譯語言實作的內建或動態載" +"入的模組。在這種情況下,你可能沒有原始檔案,或者它可能類似於 :file:" +"`mathmodule.c`,位於 C 原始碼目錄中(不在 Python 路徑中)。" #: ../../faq/library.rst:35 msgid "There are (at least) three kinds of modules in Python:" @@ -105,7 +104,6 @@ msgid "How do I make a Python script executable on Unix?" msgstr "我如何使 Python script 執行在 Unix?" #: ../../faq/library.rst:49 -#, fuzzy msgid "" "You need to do two things: the script file's mode must be executable and the " "first line must begin with ``#!`` followed by the path of the Python " @@ -139,7 +137,6 @@ msgid "" msgstr "作為檔案的第一行,使用 Python 直譯器安裝在你的平台上的路徑名稱。" #: ../../faq/library.rst:64 -#, fuzzy msgid "" "If you would like the script to be independent of where the Python " "interpreter lives, you can use the :program:`env` program. Almost all Unix " @@ -147,8 +144,8 @@ msgid "" "directory on the user's :envvar:`PATH`::" msgstr "" "如果你希望腳本獨立於 Python 直譯器所在的位置,你可以使用 :program:`env` 程" -"式。幾乎所有 Unix 變體都支援以下內容,假設 Python 直譯器位於使用者" -"的 :envvar:`PATH` 上的目錄中: ::" +"式。幾乎所有 Unix 變體都支援以下內容,假設 Python 直譯器位於使用者的 :envvar:" +"`PATH` 上的目錄中: ::" #: ../../faq/library.rst:69 msgid "#!/usr/bin/env python" @@ -164,14 +161,13 @@ msgstr "" "此你需要使用直譯器的實際絕對路徑名稱。" #: ../../faq/library.rst:75 -#, fuzzy msgid "" "Occasionally, a user's environment is so full that the :program:`/usr/bin/" "env` program fails; or there's no env program at all. In that case, you can " "try the following hack (due to Alex Rezinsky):" msgstr "" -"有時,使用者的環境太滿以至於:program:`/usr/bin/env` 程式失敗;或者根本就沒有 " -"env 程式。在這種情況下,你可以嘗試以下 hack(由於 Alex Rezinsky):" +"有時,使用者的環境太滿以至於 :program:`/usr/bin/env` 程式失敗;或者根本就沒" +"有 env 程式。在這種情況下,你可以嘗試以下 hack(由於 Alex Rezinsky):" #: ../../faq/library.rst:79 msgid "" @@ -202,19 +198,17 @@ msgid "Is there a curses/termcap package for Python?" msgstr "是否有適用於 Python 的 curses/termcap 套件?" #: ../../faq/library.rst:98 -#, fuzzy msgid "" "For Unix variants: The standard Python source distribution comes with a " "curses module in the :source:`Modules` subdirectory, though it's not " "compiled by default. (Note that this is not available in the Windows " "distribution -- there is no curses module for Windows.)" msgstr "" -"對於 Unix 變體:標準 Python 源程式碼分發版在 :source:`Modules` 子目錄中附帶一" +"對於 Unix 變體:標準 Python 原始碼分發版在 :source:`Modules` 子目錄中附帶一" "個 curses 模組,但預設情況下未編譯它。(請注意,這在 Windows 發行版中不可用——" "沒有適用於 Windows 的 curses 模組。)" #: ../../faq/library.rst:103 -#, fuzzy msgid "" "The :mod:`curses` module supports basic curses features as well as many " "additional functions from ncurses and SYSV curses such as colour, " @@ -224,8 +218,8 @@ msgid "" "category." msgstr "" ":mod:`curses` 模組支援基本的 curses 功能以及 ncurses 和 SYSV curses 的許多附" -"加功能,例如顏色、替代字元集支援、鍵盤和鼠標支援。這意味著該模組與僅具有 BSD " -"curses 的作業系統不相容,但似乎沒有任何目前維護的作業系統屬於此類型。" +"加功能,例如顏色、替代字元集支援、鍵盤和滑鼠支援。這意味著該模組與僅具有 BSD " +"curses 的作業系統不相容,但似乎沒有任何目前維護的作業系統屬於此型別。" #: ../../faq/library.rst:111 msgid "Is there an equivalent to C's onexit() in Python?" @@ -245,7 +239,8 @@ msgstr "為什麼我的訊號處理程式不起作用?" msgid "" "The most common problem is that the signal handler is declared with the " "wrong argument list. It is called as ::" -msgstr "最常見的問題是訊號處理程式是用錯誤的引數串列聲明的。它以以下形式來呼叫: ::" +msgstr "" +"最常見的問題是訊號處理程式是用錯誤的引數串列聲明的。它以以下形式來呼叫: ::" #: ../../faq/library.rst:123 msgid "handler(signum, frame)" @@ -272,13 +267,12 @@ msgid "How do I test a Python program or component?" msgstr "如何測試 Python 程式或元件?" #: ../../faq/library.rst:137 -#, fuzzy msgid "" "Python comes with two testing frameworks. The :mod:`doctest` module finds " "examples in the docstrings for a module and runs them, comparing the output " "with the expected output given in the docstring." msgstr "" -"Python 帶有兩個測試框架。 :mod:`doctest` 模組在模組的文件字串中查詢示例並運行" +"Python 帶有兩個測試框架。 :mod:`doctest` 模組在模組的文件字串中查詢範例並執行" "它們,將輸出與文件字串中給出的預期輸出進行比較。" #: ../../faq/library.rst:141 @@ -290,7 +284,6 @@ msgstr "" "模型。" #: ../../faq/library.rst:144 -#, fuzzy msgid "" "To make testing easier, you should use good modular design in your program. " "Your program should have almost all functionality encapsulated in either " @@ -301,14 +294,13 @@ msgid "" "more difficult to do." msgstr "" "為了使測試更容易,你應該在程式中使用良好的模組化設計。你的程式應該將幾乎所有" -"功能都封裝在函式或類別方法中——這有時會產生使程式運行得更快的令人驚訝和令人愉" +"功能都封裝在函式或類別方法中——這有時會產生使程式執行得更快的令人驚訝和令人愉" "快的效果(因為局部變數存取比全域存取更快)。此外,該程式應避免依賴於可變的全" -"局變數,因為這會使測試變得更加困難。" +"域變數,因為這會使測試變得更加困難。" #: ../../faq/library.rst:152 -#, fuzzy msgid "The \"global main logic\" of your program may be as simple as ::" -msgstr "你程式的「全域主邏輯」可能像一樣簡單: ::" +msgstr "你程式的 \"全域主邏輯\" 可能像下面這樣簡單: ::" #: ../../faq/library.rst:154 msgid "" @@ -319,12 +311,10 @@ msgstr "" " main_logic()" #: ../../faq/library.rst:157 -#, fuzzy msgid "at the bottom of the main module of your program." msgstr "在你的程式主模組的底端。" #: ../../faq/library.rst:159 -#, fuzzy msgid "" "Once your program is organized as a tractable collection of function and " "class behaviours, you should write test functions that exercise the " @@ -342,7 +332,6 @@ msgstr "" "設計缺陷變得容易。" #: ../../faq/library.rst:167 -#, fuzzy msgid "" "\"Support modules\" that are not intended to be the main module of a program " "may include a self-test of the module. ::" @@ -357,13 +346,12 @@ msgstr "" " self_test()" #: ../../faq/library.rst:173 -#, fuzzy msgid "" "Even programs that interact with complex external interfaces may be tested " "when the external interfaces are unavailable by using \"fake\" interfaces " "implemented in Python." msgstr "" -"即使是與復雜外部介面交互的程式也可以在外部介面不可用時透過使用 Python 中實作" +"即使是與複雜外部介面交互的程式也可以在外部介面不可用時透過使用 Python 中實作" "的 \"假\" 介面進行測試。" #: ../../faq/library.rst:179 @@ -371,19 +359,17 @@ msgid "How do I create documentation from doc strings?" msgstr "如何從文件字串建立文件?" #: ../../faq/library.rst:181 -#, fuzzy msgid "" "The :mod:`pydoc` module can create HTML from the doc strings in your Python " "source code. An alternative for creating API documentation purely from " "docstrings is `epydoc `_. `Sphinx `_ can also include docstring content." msgstr "" -":mod:`pydoc` 模組可以從 Python 源程式碼中的文件字串建立 HTML。純粹從文件字串" -"建立 API 文件的另一種方法是 `epydoc `_。 " +":mod:`pydoc` 模組可以從 Python 原始碼中的文件字串建立 HTML。純粹從文件字串建" +"立 API 文件的另一種方法是 `epydoc `_。 " "`Sphinx `_ 也可以包含文件字串內容。" #: ../../faq/library.rst:188 -#, fuzzy msgid "How do I get a single keypress at a time?" msgstr "我如何一次獲得一個按鍵?" @@ -392,8 +378,8 @@ msgid "" "For Unix variants there are several solutions. It's straightforward to do " "this using curses, but curses is a fairly large module to learn." msgstr "" -"對於 Unix 變體有幾種解決方案。使用 curses 執行此操作很直觀,但 curses 是一" -"個學習成本較大的模組。" +"對於 Unix 變體有幾種解決方案。使用 curses 執行此操作很直觀,但 curses 是一個" +"學習成本較大的模組。" #: ../../faq/library.rst:234 msgid "Threads" @@ -404,27 +390,24 @@ msgid "How do I program using threads?" msgstr "如何使用執行緒編寫程式?" #: ../../faq/library.rst:239 -#, fuzzy msgid "" "Be sure to use the :mod:`threading` module and not the :mod:`_thread` " "module. The :mod:`threading` module builds convenient abstractions on top of " "the low-level primitives provided by the :mod:`_thread` module." msgstr "" -"請務必使用 :mod:`threading` 模組而不是 :mod:`_thread` 模" -"組。 :mod:`threading` 模組在 :mod:`_thread` 模組提供的低階原語之上構建方便的" -"抽象。" +"請務必使用 :mod:`threading` 模組而不是 :mod:`_thread` 模組。 :mod:" +"`threading` 模組在 :mod:`_thread` 模組提供的低階原語之上建構方便的抽象。" #: ../../faq/library.rst:245 msgid "None of my threads seem to run: why?" msgstr "我的執行緒似乎都沒有運行:為什麼?" #: ../../faq/library.rst:247 -#, fuzzy msgid "" "As soon as the main thread exits, all threads are killed. Your main thread " "is running too quickly, giving the threads no time to do any work." msgstr "" -"一旦主執行緒退出,所有執行緒都會被殺死。你的主執行緒運行得太快,執行緒沒有時" +"一旦主執行緒退出,所有執行緒都會被殺死。你的主執行緒執行得太快,執行緒沒有時" "間做任何工作。" #: ../../faq/library.rst:250 @@ -461,15 +444,13 @@ msgstr "" "time.sleep(10) # <---------------------------!" #: ../../faq/library.rst:265 -#, fuzzy msgid "" "But now (on many platforms) the threads don't run in parallel, but appear to " "run sequentially, one at a time! The reason is that the OS thread scheduler " "doesn't start a new thread until the previous thread is blocked." msgstr "" -"但是現在(在許多平台上)執行緒不是並行運行的,而是看起來是順序運行的,一次一" -"個!原因是作業系統執行緒調度程式在前一個執行緒被阻塞之前不會啟動一個新執行" -"緒。" +"但是現在(在許多平台上)執行緒不是並行執行的,而是看起來是順序執行的,一次一" +"個!原因是作業系統執行緒排程器在前一個執行緒被阻塞之前不會啟動一個新執行緒。" #: ../../faq/library.rst:269 msgid "A simple fix is to add a tiny sleep to the start of the run function::" @@ -500,34 +481,30 @@ msgstr "" "time.sleep(10)" #: ../../faq/library.rst:282 -#, fuzzy msgid "" "Instead of trying to guess a good delay value for :func:`time.sleep`, it's " -"better to use some kind of semaphore mechanism. One idea is to use " -"the :mod:`queue` module to create a queue object, let each thread append a " -"token to the queue when it finishes, and let the main thread read as many " -"tokens from the queue as there are threads." +"better to use some kind of semaphore mechanism. One idea is to use the :mod:" +"`queue` module to create a queue object, let each thread append a token to " +"the queue when it finishes, and let the main thread read as many tokens from " +"the queue as there are threads." msgstr "" "與其嘗試為 :func:`time.sleep` 猜測一個好的延遲值,不如使用某種訊號量機制。一" -"種想法是使用 :mod:`queue` 模組建立一個隊列物件,讓每個執行緒在完成時向隊列新" -"增一個權杖,並讓主執行緒從隊列中讀取與執行緒數一樣多的權杖。" +"種想法是使用 :mod:`queue` 模組建立一個佇列物件,讓每個執行緒在完成時向佇列新" +"增一個權杖,並讓主執行緒從佇列中讀取與執行緒數一樣多的權杖。" #: ../../faq/library.rst:290 -#, fuzzy msgid "How do I parcel out work among a bunch of worker threads?" msgstr "我如何在一堆工作執行緒中分配工作?" #: ../../faq/library.rst:292 -#, fuzzy msgid "" "The easiest way is to use the :mod:`concurrent.futures` module, especially " "the :mod:`~concurrent.futures.ThreadPoolExecutor` class." msgstr "" -"最簡單的方法是使用 :mod:`concurrent.futures` 模組,尤其" -"是 :mod:`~concurrent.futures.ThreadPoolExecutor` 類別。" +"最簡單的方法是使用 :mod:`concurrent.futures` 模組,尤其是 :mod:`~concurrent." +"futures.ThreadPoolExecutor` 類別。" #: ../../faq/library.rst:295 -#, fuzzy msgid "" "Or, if you want fine control over the dispatching algorithm, you can write " "your own logic manually. Use the :mod:`queue` module to create a queue " @@ -536,10 +513,10 @@ msgid "" "``.get()`` method to return them. The class will take care of the locking " "necessary to ensure that each job is handed out exactly once." msgstr "" -"或者,如果你想對調度演算法進行精細控制,你可以手動編寫自己的邏輯。使" -"用 :mod:`queue` 模組建立一個包含作業列表的隊列。 :class:`~queue.Queue` 類別維" -"護一個物件列表,並有一個 `.put(obj)`` 方法將項目新增到隊列和一個 ``.get()`` " -"方法回傳它們。該類別將負責必要的鎖定,以確保每個作業都恰好分發一次。" +"或者,如果你想對排程演算法進行精細控制,你可以手動編寫自己的邏輯。使用 :mod:" +"`queue` 模組建立一個包含作業串列的佇列。 :class:`~queue.Queue` 類別維護一個物" +"件串列,並有一個 ``.put(obj)`` 方法將項目新增到佇列,以及一個 ``.get()`` 方法" +"回傳它們。該類別將負責必要的鎖定,以確保每個作業都恰好分發一次。" #: ../../faq/library.rst:302 msgid "Here's a trivial example::" @@ -619,10 +596,9 @@ msgstr "" "..." #: ../../faq/library.rst:358 -#, fuzzy msgid "" -"Consult the module's documentation for more details; " -"the :class:`~queue.Queue` class provides a featureful interface." +"Consult the module's documentation for more details; the :class:`~queue." +"Queue` class provides a featureful interface." msgstr "" "有關更多詳細資訊,請參閱模組的文件; :class:`~queue.Queue` 類別提供了一個功能" "強大的介面。" @@ -632,7 +608,6 @@ msgid "What kinds of global value mutation are thread-safe?" msgstr "什麼樣的全域值變化是執行緒安全的?" #: ../../faq/library.rst:365 -#, fuzzy msgid "" "A :term:`global interpreter lock` (GIL) is used internally to ensure that " "only one thread runs in the Python VM at a time. In general, Python offers " @@ -641,31 +616,29 @@ msgid "" "instruction and therefore all the C implementation code reached from each " "instruction is therefore atomic from the point of view of a Python program." msgstr "" -"內部使用 :term:`全域直譯器鎖 (GIL, global interpreter lock)`\\ 來確保一次只有" -"一個執行緒在 Python VM 中運行。通常,Python 僅提供位元組碼指令之間的執行緒切" -"換;可以透過 :func:`sys.setswitchinterval` 設定它切換的頻率。因此,從 Python " -"程式的角度來看,每條位元組碼指令以及從每條指令到達的所有 C 實作程式碼都是原子" -"的。" +"內部使用\\ :term:`全域直譯器鎖 `\\ (GIL)來確保一次" +"只有一個執行緒在 Python VM 中執行。通常,Python 僅提供位元組碼指令之間的執行" +"緒切換;可以透過 :func:`sys.setswitchinterval` 設定它切換的頻率。因此,從 " +"Python 程式的角度來看,每條位元組碼指令以及從每條指令到達的所有 C 實作程式碼" +"都是原子的。" #: ../../faq/library.rst:372 -#, fuzzy msgid "" "In theory, this means an exact accounting requires an exact understanding of " "the PVM bytecode implementation. In practice, it means that operations on " "shared variables of built-in data types (ints, lists, dicts, etc) that " "\"look atomic\" really are." msgstr "" -"從理論上講,這意味著準確的記賬需要對 PVM 位元組碼實作有準確的理解。實際上,這" -"意味著對 \"看起來原子\" 的內置資料型別(整數、列表、字典等)的共享變數的操作" +"從理論上講,這意味著準確的記帳需要對 PVM 位元組碼實作有準確的理解。實際上,這" +"意味著對 \"看起來原子\" 的內建資料型別(整數、串列、字典等)的共享變數的操作" "確實是原子的。" #: ../../faq/library.rst:377 -#, fuzzy msgid "" "For example, the following operations are all atomic (L, L1, L2 are lists, " "D, D1, D2 are dicts, x, y are objects, i, j are ints)::" msgstr "" -"例如,以下操作都是原子的(L、L1、L2 是列表,D、D1、D2 是字典,x、y 是物件," +"例如,以下操作都是原子的(L、L1、L2 是串列,D、D1、D2 是字典,x、y 是物件," "i、j 是整數): ::" #: ../../faq/library.rst:380 @@ -711,15 +684,14 @@ msgstr "" "D[x] = D[x] + 1" #: ../../faq/library.rst:399 -#, fuzzy msgid "" -"Operations that replace other objects may invoke those other " -"objects' :meth:`~object.__del__` method when their reference count reaches " -"zero, and that can affect things. This is especially true for the mass " -"updates to dictionaries and lists. When in doubt, use a mutex!" +"Operations that replace other objects may invoke those other objects' :meth:" +"`~object.__del__` method when their reference count reaches zero, and that " +"can affect things. This is especially true for the mass updates to " +"dictionaries and lists. When in doubt, use a mutex!" msgstr "" -"替換其他物件的操作可能會在引用計數達到零時叫用其他物件的 :meth:`__del__` 方" -"法,這可能會影響事情。對於字典和列表的大量更新尤其如此。如有疑問,請使用互斥" +"替換其他物件的操作可能會在引用計數達到零時呼叫其他物件的 :meth:`__del__` 方" +"法,這可能會影響事情。對於字典和串列的大量更新尤其如此。如有疑問,請使用互斥" "體!" #: ../../faq/library.rst:406 @@ -727,16 +699,15 @@ msgid "Can't we get rid of the Global Interpreter Lock?" msgstr "不能擺脫全域直譯器鎖嗎?" #: ../../faq/library.rst:408 -#, fuzzy msgid "" "The :term:`global interpreter lock` (GIL) is often seen as a hindrance to " "Python's deployment on high-end multiprocessor server machines, because a " "multi-threaded Python program effectively only uses one CPU, due to the " "insistence that (almost) all Python code can only run while the GIL is held." msgstr "" -":term:`global interpreter lock` (GIL) 通常被視為 Python 在高階多處理器伺服器" -"機器上部署的障礙,因為多執行緒 Python 程式實際上只使用一個 CPU,因為堅持(幾" -"乎)所有 Python 程式碼只能在持有 GIL 的情況下運行。" +":term:`全域直譯器鎖 `\\ (GIL)通常被視為 Python 在" +"高階多處理器伺服器機器上部署的障礙,因為多執行緒 Python 程式實際上只使用一個 " +"CPU,因為堅持(幾乎)所有 Python 程式碼只能在持有 GIL 的情況下執行。" #: ../../faq/library.rst:413 msgid "" @@ -751,7 +722,6 @@ msgid "" msgstr "" #: ../../faq/library.rst:422 -#, fuzzy msgid "" "The current work to remove the GIL is based on a `fork of Python 3.9 with " "the GIL removed `_ by Sam Gross. Prior " @@ -765,14 +735,16 @@ msgid "" "compensate for the removal of the GIL. The Python 3.9 fork is the first " "attempt at removing the GIL with an acceptable performance impact." msgstr "" -"回到 Python 1.5 時代,Greg Stein 實際上實作了一個全面的補丁集( \"自由執行緒" -"\" 補丁),刪除了 GIL 並用細粒度鎖定取而代之。 Adam Olsen 最近在他的 `python-" -"safethread `_ 項目中做了" -"一個類似的實驗。不幸的是,這兩個實驗都表現出單執行緒性能的急劇下降(至少慢了 " -"30%),這是由於需要大量的細粒度鎖定來補償 GIL 的移除。" +"目前移除 GIL 的工作是基於 Sam Gross 的\\ `Python 3.9 移除 GIL 的 fork " +"`_\\ 。在此之前,早在 Python 1.5 時代," +"Greg Stein 實際上就實作了一套全面的 patch(即 \"自由執行緒\" patch),移除了 " +"GIL 並以細粒度鎖定取而代之。Adam Olsen 在他的 `python-safethread `_ 專案中做了一個類似的實驗。不幸" +"的是,這兩個早期實驗都表現出單執行緒效能的急劇下降(至少慢了 30%),這是由於" +"需要大量的細粒度鎖定來補償 GIL 的移除。Python 3.9 fork 是第一個以可接受的效能" +"影響來移除 GIL 的嘗試。" #: ../../faq/library.rst:437 -#, fuzzy msgid "" "The presence of the GIL in current Python releases doesn't mean that you " "can't make good use of Python on multi-CPU machines! You just have to be " @@ -782,24 +754,23 @@ msgid "" "doing so; the :mod:`multiprocessing` module provides a lower-level API in " "case you want more control over dispatching of tasks." msgstr "" -"這並不意味著你不能在多 CPU 機器上用好 Python!你只需要創造性地將工作分配給多" -"個*行程*而​​不是多個*執行緒*。新的 :mod:`concurrent.futures` 模組中" +"這並不意味著你不能在多 CPU 機器上善用 Python!你只需要創造性地將工作分配給多" +"個\\ *行程*\\ 而不是多個\\ *執行緒*\\ 。新的 :mod:`concurrent.futures` 模組中" "的 :class:`~concurrent.futures.ProcessPoolExecutor` 類別提供了一種簡單的方" -"法; :mod:`multiprocessing` 模組提供了一個較低階別的 API,以防你希望更好地控" -"制任務的調度。" +"法; :mod:`multiprocessing` 模組提供了一個較低階的 API,以防你希望更好地控制" +"任務的排程。" #: ../../faq/library.rst:446 -#, fuzzy msgid "" "Judicious use of C extensions will also help; if you use a C extension to " "perform a time-consuming task, the extension can release the GIL while the " "thread of execution is in the C code and allow other threads to get some " -"work done. Some standard library modules such as :mod:`zlib` " -"and :mod:`hashlib` already do this." +"work done. Some standard library modules such as :mod:`zlib` and :mod:" +"`hashlib` already do this." msgstr "" "明智地使用 C 擴充也會有所幫助;如果你使用 C 擴充來執行耗時任務,則該擴充可以" -"在執行執行緒在 C 程式碼中時釋放 GIL,並允許其他執行緒完成一些工作。一些標準函" -"式庫模組,例如 :mod:`zlib` 和 :mod:`hashlib` 已經這樣做了。" +"在執行緒身處 C 程式碼中時釋放 GIL,並允許其他執行緒完成一些工作。一些標準函式" +"庫模組,例如 :mod:`zlib` 和 :mod:`hashlib` 已經這樣做了。" #: ../../faq/library.rst:452 msgid "" @@ -826,19 +797,16 @@ msgid "How do I delete a file? (And other file questions...)" msgstr "如何刪除檔案?(以及其他檔案問題...)" #: ../../faq/library.rst:467 -#, fuzzy msgid "" "Use ``os.remove(filename)`` or ``os.unlink(filename)``; for documentation, " -"see the :mod:`os` module. The two functions are " -"identical; :func:`~os.unlink` is simply the name of the Unix system call for " -"this function." +"see the :mod:`os` module. The two functions are identical; :func:`~os." +"unlink` is simply the name of the Unix system call for this function." msgstr "" -"使用 ``os.remove(filename)`` 或 ``os.unlink(filename)``;有關文件,請參" -"閱 :mod:`os` 模組。這兩個功能是相同的; :func:`~os.unlink` 只是這個函式的 " -"Unix 系統呼叫的名稱。" +"使用 ``os.remove(filename)`` 或 ``os.unlink(filename)``;有關文件,請參閱 :" +"mod:`os` 模組。這兩個功能是相同的; :func:`~os.unlink` 只是這個函式的 Unix 系" +"統呼叫的名稱。" #: ../../faq/library.rst:471 -#, fuzzy msgid "" "To remove a directory, use :func:`os.rmdir`; use :func:`os.mkdir` to create " "one. ``os.makedirs(path)`` will create any intermediate directories in " @@ -846,44 +814,41 @@ msgid "" "directories as long as they're empty; if you want to delete an entire " "directory tree and its contents, use :func:`shutil.rmtree`." msgstr "" -"要刪除目錄,請使用 :func:`os.rmdir`;使用 :func:`os.mkdir` 建立一個。 " -"``os.makedirs(path)`` 將在 ``path`` 中建立任何不存在的中間目錄。 " -"``os.removedirs(path)`` 將刪除中間目錄,只要它們是空的;如果要刪除整個目錄樹" -"及其內容,請使用 :func:`shutil.rmtree`。" +"要刪除目錄,請使用 :func:`os.rmdir`;使用 :func:`os.mkdir` 建立一個。 ``os." +"makedirs(path)`` 將在 ``path`` 中建立任何不存在的中間目錄。 ``os." +"removedirs(path)`` 將刪除中間目錄,只要它們是空的;如果要刪除整個目錄樹及其內" +"容,請使用 :func:`shutil.rmtree`。" #: ../../faq/library.rst:477 msgid "To rename a file, use ``os.rename(old_path, new_path)``." msgstr "要重新命名檔案,請使用 ``os.rename(old_path, new_path)``。" #: ../../faq/library.rst:479 -#, fuzzy msgid "" "To truncate a file, open it using ``f = open(filename, \"rb+\")``, and use " "``f.truncate(offset)``; offset defaults to the current seek position. " -"There's also ``os.ftruncate(fd, offset)`` for files opened " -"with :func:`os.open`, where *fd* is the file descriptor (a small integer)." +"There's also ``os.ftruncate(fd, offset)`` for files opened with :func:`os." +"open`, where *fd* is the file descriptor (a small integer)." msgstr "" -"要截斷一個檔案,使用``f = open(filename, \"rb+\")``打開它,然後使用" -"``f.truncate(offset)``;偏移量預設為目前搜尋位置。對於使用 :func:`os.open` 打" -"開的檔案,還有 ``os.ftruncate(fd, offset)``,其中 *fd* 是檔案描述器(一個小整" +"要截斷一個檔案,使用 ``f = open(filename, \"rb+\")`` 打開它,然後使用 ``f." +"truncate(offset)``;偏移量預設為目前搜尋位置。對於使用 :func:`os.open` 打開的" +"檔案,還有 ``os.ftruncate(fd, offset)``,其中 *fd* 是檔案描述器(一個小整" "數)。" #: ../../faq/library.rst:484 msgid "" "The :mod:`shutil` module also contains a number of functions to work on " -"files including :func:`~shutil.copyfile`, :func:`~shutil.copytree`, " -"and :func:`~shutil.rmtree`." +"files including :func:`~shutil.copyfile`, :func:`~shutil.copytree`, and :" +"func:`~shutil.rmtree`." msgstr "" -":mod:`shutil` 模組還包含許多用於檔案處理的函式,包" -"括 :func:`~shutil.copyfile`、:func:`~shutil.copytree` " -"和 :func:`~shutil.rmtree`。" +":mod:`shutil` 模組還包含許多用於檔案處理的函式,包括 :func:`~shutil." +"copyfile`、:func:`~shutil.copytree` 和 :func:`~shutil.rmtree`。" #: ../../faq/library.rst:490 msgid "How do I copy a file?" msgstr "如何複製檔案?" #: ../../faq/library.rst:492 -#, fuzzy msgid "" "The :mod:`shutil` module contains a :func:`~shutil.copyfile` function. Note " "that on Windows NTFS volumes, it does not copy `alternate data streams " @@ -893,29 +858,27 @@ msgid "" "permissions and metadata, though using :func:`shutil.copy2` instead will " "preserve most (though not all) of it." msgstr "" -":mod:`shutil` 模組包含一個 :func:`~shutil.copyfile` 函式。請注意,在 Windows " -"NTFS 卷上,它不會複製 `alternate data streams `_ 也不會複製 `resource forks `__ 在 macOS HFS+ 卷上,儘管現在兩者都很" -"少使用。它也不會複製檔案權限和元資料,儘管使用 :func:`shutil.copy2` 會保留其" -"中的大部分(儘管不是全部)。" +":mod:`shutil` 模組包含一個 :func:`~shutil.copyfile` 函式。請注意,它不會複製 " +"Windows NTFS 磁碟區上的 `alternate data streams `_,也不會複製 macOS HFS+ 磁碟區上的 " +"`resource forks `__,儘管現在兩" +"者都很少使用。它也不會複製檔案權限和元資料,儘管改用 :func:`shutil.copy2` 會" +"保留其中的大部分(儘管不是全部)。" #: ../../faq/library.rst:503 msgid "How do I read (or write) binary data?" msgstr "如何讀取(或寫入)二進位制資料?" #: ../../faq/library.rst:505 -#, fuzzy msgid "" -"To read or write complex binary data formats, it's best to use " -"the :mod:`struct` module. It allows you to take a string containing binary " -"data (usually numbers) and convert it to Python objects; and vice versa." +"To read or write complex binary data formats, it's best to use the :mod:" +"`struct` module. It allows you to take a string containing binary data " +"(usually numbers) and convert it to Python objects; and vice versa." msgstr "" "要讀取或寫入複雜的二進制資料格式,最好使用 :mod:`struct` 模組。它允許你取得包" "含二進制資料(通常是數字)的字串並將其轉換為 Python 物件;反之亦然。" #: ../../faq/library.rst:509 -#, fuzzy msgid "" "For example, the following code reads two 2-byte integers and one 4-byte " "integer in big-endian format from a file::" @@ -938,26 +901,23 @@ msgstr "" " x, y, z = struct.unpack(\">hhl\", s)" #: ../../faq/library.rst:518 -#, fuzzy msgid "" "The '>' in the format string forces big-endian data; the letter 'h' reads " "one \"short integer\" (2 bytes), and 'l' reads one \"long integer\" (4 " "bytes) from the string." msgstr "" -"格式字串中的 \">\" 強制使用大端資料;字母 'h' 讀取一個 \"短整數\" (2 位元" -"組), 'l' 從字串中讀取一個 \"長整數\" (4 位元組)。" +"格式字串中的 '>' 強制使用大端資料;字母 'h' 讀取一個 \"短整數\"(2 位元" +"組),'l' 從字串中讀取一個 \"長整數\"(4 位元組)。" #: ../../faq/library.rst:522 -#, fuzzy msgid "" "For data that is more regular (e.g. a homogeneous list of ints or floats), " "you can also use the :mod:`array` module." msgstr "" -"對於更規則的資料(例如,整數或浮點數的同類列表),你還可以使用 :mod:`array` " +"對於更規則的資料(例如,整數或浮點數的同質串列),你還可以使用 :mod:`array` " "模組。" #: ../../faq/library.rst:527 -#, fuzzy msgid "" "To read and write binary data, it is mandatory to open the file in binary " "mode (here, passing ``\"rb\"`` to :func:`open`). If you use ``\"r\"`` " @@ -965,24 +925,23 @@ msgid "" "will return :class:`str` objects rather than :class:`bytes` objects." msgstr "" "要讀取和寫入二進位資料,必須以二進位模式打開檔案(這裡,將 ``\"rb\"`` 傳遞" -"給 :func:`open`)。如果你改用 ``\"r\"``\\ (預設設定),檔案將以文本模式打開,並" -"且 ``f.read()`` 將回傳 :class:`str` 物件而不是 :class:`bytes` 物件。" +"給 :func:`open`)。如果你改用 ``\"r\"``\\ (預設設定),檔案將以文字模式打" +"開,並且 ``f.read()`` 將回傳 :class:`str` 物件而不是 :class:`bytes` 物件。" #: ../../faq/library.rst:535 msgid "I can't seem to use os.read() on a pipe created with os.popen(); why?" msgstr "我似乎無法在用 os.popen() 建立的 pipe 上使用 os.read();為什麼?" #: ../../faq/library.rst:537 -#, fuzzy msgid "" ":func:`os.read` is a low-level function which takes a file descriptor, a " "small integer representing the opened file. :func:`os.popen` creates a high-" "level file object, the same type returned by the built-in :func:`open` " -"function. Thus, to read *n* bytes from a pipe *p* created " -"with :func:`os.popen`, you need to use ``p.read(n)``." +"function. Thus, to read *n* bytes from a pipe *p* created with :func:`os." +"popen`, you need to use ``p.read(n)``." msgstr "" ":func:`os.read` 是一個低階函式,它接受一個檔案描述器,一個代表打開檔案的小整" -"數。 :func:`os.popen` 建立一個高階檔案物件,與內置的 :func:`open` 函式回傳的" +"數。 :func:`os.popen` 建立一個高階檔案物件,與內建的 :func:`open` 函式回傳的" "型別相同。因此,要從使用 :func:`os.popen` 建立的管道 *p* 中讀取 *n* 個位元" "組,你需要使用 ``p.read(n)``。" @@ -1018,7 +977,6 @@ msgstr "" "Python :term:`檔案物件 `\\ 是低階 C 檔案描述器的高階抽象層。" #: ../../faq/library.rst:562 -#, fuzzy msgid "" "For most file objects you create in Python via the built-in :func:`open` " "function, ``f.close()`` marks the Python file object as being closed from " @@ -1026,12 +984,11 @@ msgid "" "descriptor. This also happens automatically in ``f``'s destructor, when " "``f`` becomes garbage." msgstr "" -"對於你透過內置的 :func:`open` 函式在 Python 中建立的大多數檔案物件," -"``f.close()`` 從 Python 的角度將 Python 檔案物件標記為已關閉,並安排關閉底層 " -"C 檔案描述器。當 ``f`` 變成垃圾時,這也會自動發生在 ``f`` 的析構函式中。" +"對於你透過內建的 :func:`open` 函式在 Python 中建立的大多數檔案物件,``f." +"close()`` 從 Python 的角度將 Python 檔案物件標記為已關閉,並安排關閉底層 C 檔" +"案描述器。當 ``f`` 變成垃圾時,這也會自動發生在 ``f`` 的析構函式中。" #: ../../faq/library.rst:568 -#, fuzzy msgid "" "But stdin, stdout and stderr are treated specially by Python, because of the " "special status also given to them by C. Running ``sys.stdout.close()`` " @@ -1039,11 +996,10 @@ msgid "" "associated C file descriptor." msgstr "" "但是 stdin、stdout 和 stderr 被 Python 特殊對待,因為 C 也賦予它們特殊的狀" -"態。運行 ``sys.stdout.close()`` 將 Python 級檔案物件標記為已關閉,但是 * " -"not* 關閉關聯的 C 檔案描述器。" +"態。執行 ``sys.stdout.close()`` 將 Python 級檔案物件標記為已關閉,但\\ *不會" +"*\\ 關閉關聯的 C 檔案描述器。" #: ../../faq/library.rst:573 -#, fuzzy msgid "" "To close the underlying C file descriptor for one of these three, you should " "first be sure that's what you really want to do (e.g., you may confuse " @@ -1075,22 +1031,21 @@ msgid "What WWW tools are there for Python?" msgstr "Python 有哪些 WWW 工具?" #: ../../faq/library.rst:590 -#, fuzzy msgid "" "See the chapters titled :ref:`internet` and :ref:`netdata` in the Library " "Reference Manual. Python has many modules that will help you build server-" "side and client-side web systems." msgstr "" "請參閱函式庫參考手冊中標題為 :ref:`internet` 和 :ref:`netdata` 的章節。 " -"Python 有許多模組可以幫助你構建伺服器端和用戶端 Web 系統。" +"Python 有許多模組可以幫助你建構伺服器端和使用者端 Web 系統。" #: ../../faq/library.rst:596 msgid "" "A summary of available frameworks is maintained by Paul Boddie at https://" "wiki.python.org/moin/WebProgramming\\ ." msgstr "" -"Paul Boddie 有在 https://wiki.python.org/moin/" -"WebProgramming\\ 維護可用框架的摘要。" +"Paul Boddie 有在 https://wiki.python.org/moin/WebProgramming\\ 維護可用框架的" +"摘要。" #: ../../faq/library.rst:601 msgid "What module should I use to help with generating HTML?" @@ -1101,8 +1056,8 @@ msgid "" "You can find a collection of useful links on the `Web Programming wiki page " "`_." msgstr "" -"你可以在 \"網頁程式維基頁面 \" 上找到一組有用的鏈接。" +"你可以在 \"網頁程式維基頁面 \" " +"上找到一組有用的鏈接。" #: ../../faq/library.rst:610 msgid "How do I send mail from a Python script?" @@ -1113,13 +1068,12 @@ msgid "Use the standard library module :mod:`smtplib`." msgstr "使用標準函式庫模組 :mod:`smtplib`。" #: ../../faq/library.rst:614 -#, fuzzy msgid "" "Here's a very simple interactive mail sender that uses it. This method will " "work on any host that supports an SMTP listener. ::" msgstr "" -"這是一個使用它的非常簡單的交互式郵件發件人。此方法適用於任何支援 SMTP 偵聽器" -"的主機。: ::" +"這是一個使用它的非常簡單互動式郵件寄送工具。此方法適用於任何支援 SMTP " +"listener 的主機。 ::" #: ../../faq/library.rst:617 msgid "" @@ -1195,7 +1149,6 @@ msgid "" msgstr ":mod:`select` 模組通常用於幫助處理 socket 上的非同步 I/O。" #: ../../faq/library.rst:659 -#, fuzzy msgid "" "To prevent the TCP connect from blocking, you can set the socket to non-" "blocking mode. Then when you do the :meth:`~socket.socket.connect`, you " @@ -1205,24 +1158,23 @@ msgid "" "return different values, so you're going to have to check what's returned on " "your system." msgstr "" -"為防止 TCP 連接阻塞,可以將 socket 設定為非阻塞模式。然後當你執" -"行 :meth:`socket.connect` 時,你要麼立即連接(不太可能),要麼得到一個例外," -"其中包含錯誤號 ``.errno``。 ``errno.EINPROGRESS`` 表示連接正在進行中,但尚未" -"完成。不同的作業系統將回傳不同的值,因此你將不得不檢查系統回傳的內容。" +"為防止 TCP 連接阻塞,可以將 socket 設定為非阻塞模式。然後當你執行 :meth:" +"`~socket.socket.connect` 時,你要麼立即連接(不太可能),要麼得到一個例外,其" +"中包含錯誤號 ``.errno``。 ``errno.EINPROGRESS`` 表示連接正在進行中,但尚未完" +"成。不同的作業系統將回傳不同的值,因此你將不得不檢查系統回傳的內容。" #: ../../faq/library.rst:667 -#, fuzzy msgid "" "You can use the :meth:`~socket.socket.connect_ex` method to avoid creating " -"an exception. It will just return the errno value. To poll, you can " -"call :meth:`~socket.socket.connect_ex` again later -- ``0`` or " -"``errno.EISCONN`` indicate that you're connected -- or you can pass this " -"socket to :meth:`select.select` to check if it's writable." +"an exception. It will just return the errno value. To poll, you can call :" +"meth:`~socket.socket.connect_ex` again later -- ``0`` or ``errno.EISCONN`` " +"indicate that you're connected -- or you can pass this socket to :meth:" +"`select.select` to check if it's writable." msgstr "" -"你可以使用 :meth:`socket.connect_ex` 方法來避免建立例外。它只會回傳 errno " -"值。要輪詢,你可以稍後再次呼叫 :meth:`socket.connect_ex` - ``0`` 或 " -"``errno.EISCONN`` 表示你已連接 - 或者你可以將此 socket 傳遞" -"給 :meth:`select.select` 檢查它是否可寫。" +"你可以使用 :meth:`~socket.socket.connect_ex` 方法來避免建立例外。它只會回傳 " +"errno 值。要輪詢,你可以稍後再次呼叫 :meth:`~socket.socket.connect_ex` - " +"``0`` 或 ``errno.EISCONN`` 表示你已連接 - 或者你可以將此 socket 傳遞給 :meth:" +"`select.select` 檢查它是否可寫。" #: ../../faq/library.rst:675 msgid "" @@ -1248,19 +1200,17 @@ msgid "Yes." msgstr "有的。" #: ../../faq/library.rst:690 -#, fuzzy msgid "" "Interfaces to disk-based hashes such as :mod:`DBM ` and :mod:`GDBM " -"` are also included with standard Python. There is also " -"the :mod:`sqlite3` module, which provides a lightweight disk-based " -"relational database." +"` are also included with standard Python. There is also the :mod:" +"`sqlite3` module, which provides a lightweight disk-based relational " +"database." msgstr "" "基於磁碟的雜湊介面,例如 :mod:`DBM ` 和 :mod:`GDBM ` 也包" "含在標準 Python 中。還有 :mod:`sqlite3` 模組,它提供了一個輕量級的基於磁碟的" "關係資料庫。" #: ../../faq/library.rst:695 -#, fuzzy msgid "" "Support for most relational databases is available. See the " "`DatabaseProgramming wiki page `,而任何對其 :meth:`!__next__` method 的進一步呼叫,都只會再" +"次引發 :exc:`StopIteration`。疊代器必須有一個 :meth:`~iterator.__iter__` " +"method,它會回傳疊代器物件本身,所以每個疊代器也都是可疊代物件,且可以用於大" +"多數適用其他可疊代物件的場合。一個明顯的例外,是嘗試多遍疊代 (multiple " +"iteration passes) 的程式碼。一個容器物件(像是 :class:`list`)在每次你將它傳" +"遞給 :func:`iter` 函式或在 :keyword:`for` 迴圈中使用它時,都會產生一個全新的" +"疊代器。使用疊代器嘗試此事(多遍疊代)時,只會回傳在前一遍疊代中被用過的、同" +"一個已耗盡的疊代器物件,使其看起來就像一個空的容器。" #: ../../glossary.rst:891 msgid "More information can be found in :ref:`typeiter`." @@ -2093,7 +2101,6 @@ msgid "list" msgstr "list(串列)" #: ../../glossary.rst:951 -#, fuzzy msgid "" "A built-in Python :term:`sequence`. Despite its name it is more akin to an " "array in other languages than to a linked list since access to elements is " @@ -2101,7 +2108,7 @@ msgid "" msgstr "" "一個 Python 內建的 :term:`sequence` (序列)。儘管它的名字是 list,它其實更類" "似其他語言中的一個陣列 (array) 而較不像一個鏈結串列 (linked list),因為存取元" -"素的時間複雜度是 *O*\\ (1)。" +"素的時間複雜度是 *O*\\ (1)。詳情請參閱\\ :ref:`time-complexity`\\ 。" #: ../../glossary.rst:954 msgid "list comprehension" @@ -3339,7 +3346,7 @@ msgstr ":term:`standard library` 的縮寫。" #: ../../glossary.rst:1525 msgid "steal" -msgstr "" +msgstr "steal(竊取)" #: ../../glossary.rst:1527 msgid "" @@ -3348,10 +3355,13 @@ msgid "" "reference after the call. Generally, functions that \"steal\" an argument do " "so even if they fail." msgstr "" +"在 Python 的 C API 中,「*竊取 (stealing)*」一個引數意味著該引數的所有權會轉" +"移給被呼叫的函式。呼叫者在呼叫之後就不可以再使用該參照。通常,會「竊取」引數" +"的函式,即使呼叫失敗,也依然會竊取該引數。" #: ../../glossary.rst:1532 msgid "See :ref:`api-refcountdetails` for a full explanation." -msgstr "" +msgstr "請參閱 :ref:`api-refcountdetails`\\ 以獲得完整的說明。" #: ../../glossary.rst:1533 msgid "strong reference" diff --git a/howto/a-conceptual-overview-of-asyncio.po b/howto/a-conceptual-overview-of-asyncio.po index 008ca2b690..f9423dbb09 100644 --- a/howto/a-conceptual-overview-of-asyncio.po +++ b/howto/a-conceptual-overview-of-asyncio.po @@ -212,6 +212,10 @@ msgid "" "also exist as instances of :class:`collections.abc.Coroutine` -- a " "distinction that matters for type checking." msgstr "" +"「協程函式」和「協程物件」這兩個詞經常被混用,統稱為「協程」。這可能會造成混" +"淆!在本文中,協程專指協程物件,更精確地說,是 :class:`types." +"CoroutineType`\\ (原生協程)的實例。請注意,協程也可能是 :class:" +"`collections.abc.Coroutine` 的實例——這個區別在型別檢查中很重要。" #: ../../howto/a-conceptual-overview-of-asyncio.rst:123 msgid "" diff --git a/howto/annotations.po b/howto/annotations.po index 7a8595c7fc..6d11c6c43e 100644 --- a/howto/annotations.po +++ b/howto/annotations.po @@ -299,16 +299,15 @@ msgstr "" "區域變數``。" #: ../../howto/annotations.rst:156 -#, fuzzy msgid "" "If ``o`` is a wrapped callable using :func:`functools.update_wrapper`, :deco:" "`functools.wraps`, or :func:`functools.partial`, iteratively unwrap it by " "accessing either ``o.__wrapped__`` or ``o.func`` as appropriate, until you " "have found the root unwrapped function." msgstr "" -"如果 ``o`` 是使用 :func:`functools.update_wrapper`、:func:`functools.wraps` " -"或 :func:`functools.partial` 包裝的 callable ,請依據需求,透過存取 ``o." -"__wrapped__`` 或 ``o.func`` 來疊代解開它,直到找到根解包函式。" +"如果 ``o`` 是使用 :func:`functools.update_wrapper`、:deco:`functools." +"wraps` 或 :func:`functools.partial` 包裝的 callable ,請依據需求,透過存取 " +"``o.__wrapped__`` 或 ``o.func`` 來疊代解開它,直到找到根解包函式。" #: ../../howto/annotations.rst:160 msgid "" diff --git a/howto/curses.po b/howto/curses.po index 951b3a628c..fdfa29d312 100644 --- a/howto/curses.po +++ b/howto/curses.po @@ -103,6 +103,8 @@ msgid "" "third-party :pypi:`windows-curses` package provides the same interface on " "Windows." msgstr "" +"Windows 版本的 Python 並未包含 :mod:`curses` 模組。第三方 :pypi:`windows-" +"curses` 套件在 Windows 上提供了相同的介面。" #: ../../howto/curses.rst:63 msgid "The Python curses module" @@ -481,6 +483,10 @@ msgid "" "this defaults to the default system encoding as returned by :func:`locale." "getencoding`." msgstr "" +":meth:`~curses.window.addstr` 方法接受 Python 字串或位元組字串作為要顯示的" +"值。位元組字串的內容會被原封不動地傳送到終端機。在未支援寬字元的建置版本中," +"字串會用該視窗的 :attr:`~window.encoding` 屬性值來編碼;此屬性預設為 :func:" +"`locale.getencoding` 所回傳的系統預設編碼。" #: ../../howto/curses.rst:307 msgid "" @@ -495,6 +501,9 @@ msgid "" "`ACS_ULCORNER` is the upper left corner of a box (handy for drawing " "borders). You can also use the appropriate Unicode character." msgstr "" +"終端機替代字元集的字元都有提供對應的常數。舉例來說,:const:`ACS_PLMINUS` 是一" +"個 +/- 符號,而 :const:`ACS_ULCORNER` 則是方框的左上角(在繪製邊框時很好" +"用)。你也可以直接使用對應的 Unicode 字元。" #: ../../howto/curses.rst:317 msgid "" @@ -515,6 +524,9 @@ msgid "" "leaves the cursor wherever the last update put it, instead of moving it back " "to the window's cursor position." msgstr "" +"如果你的應用程式完全不需要閃爍游標,可以呼叫 ``curs_set(False)`` 使其隱藏。視" +"窗方法 :meth:`~curses.window.leaveok` 則有不同的作用:當其引數為真時,curses " +"會讓游標留在最後一次更新所在的位置,而不是把它移回視窗的游標位置。" #: ../../howto/curses.rst:334 msgid "Attributes and Color" @@ -705,7 +717,7 @@ msgstr "" #: ../../howto/curses.rst:436 msgid "There are three methods for getting input from a window:" -msgstr "" +msgstr "有三種方法可以取得視窗的輸入:" #: ../../howto/curses.rst:438 msgid "" @@ -714,6 +726,9 @@ msgid "" "called earlier. You can optionally specify a coordinate to which the cursor " "should be moved before pausing." msgstr "" +":meth:`~curses.window.get_wch` 會重新整理螢幕,然後等待使用者按下按鍵,如果先" +"前呼叫過 :func:`~curses.echo`,還會顯示該按鍵。你可以選擇性地指定一個座標,讓" +"游標在暫停前先移動到該處。" #: ../../howto/curses.rst:443 msgid "" @@ -722,6 +737,9 @@ msgid "" "encoding in the current locale, so a character encoded with several bytes " "takes several calls, one byte per call." msgstr "" +":meth:`~curses.window.getch` 做的是同樣的事情,但回傳的是按鍵的代碼而不是字" +"元。在 ncurses 中,這會是該按鍵在目前語言環境 (locale) 中編碼的單一位元組,因" +"此以多個位元組編碼的字元需要多次呼叫,每次呼叫回傳一個位元組。" #: ../../howto/curses.rst:449 msgid "" @@ -729,6 +747,9 @@ msgid "" "string: an ordinary key as a 1-character string, and a special key as its " "name, such as ``KEY_UP``." msgstr "" +":meth:`~curses.window.getkey` 做的事情和 :meth:`!getch` 相同,但回傳的是字" +"串:一般按鍵會以長度為 1 的字串回傳,特殊按鍵則以其名稱回傳,例如 " +"``KEY_UP``。" #: ../../howto/curses.rst:454 msgid "" @@ -741,6 +762,12 @@ msgid "" "specified delay (measured in tenths of a second), the read fails the same " "way." msgstr "" +"你可以使用視窗方法 :meth:`~curses.window.nodelay` 來不等待使用者輸入。呼叫 " +"``nodelay(True)`` 之後,該視窗的讀取操作會變成非阻塞的。為了表示目前沒有可用" +"的輸入,:meth:`!get_wch` 和 :meth:`!getkey` 會引發例外,而 :meth:`!getch` 會" +"回傳 ``-1``。此外還有一個 :func:`~curses.halfdelay` 函式,可以用來(實際上)" +"為每次讀取設定一個計時器;如果在指定的延遲時間內(以十分之一秒為單位)沒有可" +"用的輸入,讀取就會以同樣的方式失敗。" #: ../../howto/curses.rst:465 msgid "" @@ -750,6 +777,10 @@ msgid "" "const:`curses.KEY_PPAGE`, :const:`curses.KEY_HOME`, or :const:`curses." "KEY_LEFT`. The main loop of your program may look something like this::" msgstr "" +"諸如 Page Up、Home 或方向鍵之類的特殊按鍵,這三種方法都會回傳其中一個 :ref:" +"`KEY_* 常數 `,其值都大於 255。你可以將回傳值和諸如 :" +"const:`curses.KEY_PPAGE`、:const:`curses.KEY_HOME` 或 :const:`curses." +"KEY_LEFT` 之類的常數做比較。你的程式主迴圈可能會長得像這樣: ::" #: ../../howto/curses.rst:473 msgid "" @@ -762,6 +793,14 @@ msgid "" " elif c == curses.KEY_HOME:\n" " x = y = 0" msgstr "" +"while True:\n" +" c = stdscr.get_wch()\n" +" if c == 'p':\n" +" PrintDocument()\n" +" elif c == 'q':\n" +" break # 跳出 while 迴圈\n" +" elif c == curses.KEY_HOME:\n" +" x = y = 0" #: ../../howto/curses.rst:482 msgid "" @@ -781,6 +820,9 @@ msgid "" "and the Enter key, which terminates the line. It returns a bytes object, and " "can optionally be limited to a fixed number of bytes. ::" msgstr "" +"還有一個方法可以取得整行輸入,:meth:`~curses.window.getstr`。它不常被使用,因" +"為它的功能相當有限;可用的編輯按鍵只有清除字元和刪除字元,以及用來結束該行的 " +"Enter 鍵。它會回傳一個 bytes 物件,也可以選擇性地限制為固定的位元組數。 ::" #: ../../howto/curses.rst:496 msgid "" @@ -789,6 +831,10 @@ msgid "" "# Get a line of at most 15 bytes, with the cursor on the top line\n" "s = stdscr.getstr(0,0, 15)" msgstr "" +"curses.echo() # 啟用字元回顯\n" +"\n" +"# 取得最多 15 個位元組的一行,游標位於頂端那一行\n" +"s = stdscr.getstr(0,0, 15)" #: ../../howto/curses.rst:501 msgid "" diff --git a/howto/descriptor.po b/howto/descriptor.po index fe4c4ebdc2..6bce53925a 100644 --- a/howto/descriptor.po +++ b/howto/descriptor.po @@ -78,7 +78,6 @@ msgstr "" "這種程度的細節。" #: ../../howto/descriptor.rst:28 -#, fuzzy msgid "" "The last section has pure Python equivalents for built-in descriptors that " "are written in C. Read this if you're curious about how functions turn into " @@ -86,8 +85,8 @@ msgid "" "`classmethod`, :deco:`staticmethod`, :deco:`property`, and :term:`__slots__`." msgstr "" "最後一個章節提供以 C 語言撰寫的內建描述器的純 Python 等價實作。如果你好奇函式" -"如何轉變為綁定方法,或者想了解常見工具如 :func:`classmethod`、:func:" -"`staticmethod`、:func:`property` 和 :term:`__slots__` 的實作方式,請閱讀此章" +"如何轉變為綁定方法,或者想了解常見工具如 :deco:`classmethod`、:deco:" +"`staticmethod`、:deco:`property` 和 :term:`__slots__` 的實作方式,請閱讀此章" "節。" #: ../../howto/descriptor.rst:36 @@ -623,7 +622,6 @@ msgstr "" "料在這件事上有發言權。" #: ../../howto/descriptor.rst:319 -#, fuzzy msgid "" "Descriptors are used throughout the language. It is how functions turn into " "bound methods. Common tools like :deco:`classmethod`, :deco:" @@ -631,7 +629,7 @@ msgid "" "all implemented as descriptors." msgstr "" "描述器在整個語言中被廣泛使用。函式就是透過這種方式轉變為綁定方法。常見工具" -"如 :func:`classmethod`、:func:`staticmethod`、:func:`property` 和 :func:" +"如 :deco:`classmethod`、:deco:`staticmethod`、:deco:`property` 和 :deco:" "`functools.cached_property` 都是以描述器實作的。" #: ../../howto/descriptor.rst:326 @@ -1819,7 +1817,7 @@ msgstr "" msgid "" "Using the non-data descriptor protocol, a pure Python version of :deco:" "`staticmethod` would look like this:" -msgstr "" +msgstr "使用非資料描述器協定,:deco:`staticmethod` 的純 Python 版本大致如下:" #: ../../howto/descriptor.rst:1331 msgid "" @@ -1930,7 +1928,7 @@ msgstr "" msgid "" "Using the non-data descriptor protocol, a pure Python version of :deco:" "`classmethod` would look like this:" -msgstr "" +msgstr "使用非資料描述器協定,:deco:`classmethod` 的純 Python 版本大致如下:" #: ../../howto/descriptor.rst:1471 msgid "" @@ -2069,6 +2067,8 @@ msgid "" "5. Blocks tools like :deco:`functools.cached_property` which require an " "instance dictionary to function correctly:" msgstr "" +"5. 阻擋像 :deco:`functools.cached_property` 這類需要實例字典才能正常運作的工" +"具:" #: ../../howto/descriptor.rst:1610 msgid "" diff --git a/howto/enum.po b/howto/enum.po index cc950d0e18..59c4fec3c5 100644 --- a/howto/enum.po +++ b/howto/enum.po @@ -531,6 +531,8 @@ msgid "" "By default, enumerations allow multiple names as aliases for the same value. " "When this behavior isn't desired, you can use the :deco:`unique` decorator::" msgstr "" +"預設情況下,列舉允許多個名稱作為同一個值的別名。當不需要此行為時,你可以使" +"用 :deco:`unique` 裝飾器: ::" #: ../../howto/enum.rst:261 msgid "" @@ -1005,6 +1007,8 @@ msgid "" "produce very strange results at runtime, such as members being equal to each " "other::" msgstr "" +"不支援將 :deco:`~dataclasses.dataclass` 裝飾器新增至 :class:`Enum` 及其子類" +"別。這不會引發任何錯誤,但會在執行時產生非常奇怪的結果,例如成員彼此相等: ::" #: ../../howto/enum.rst:517 msgid "" diff --git a/howto/functional.po b/howto/functional.po index b3782af209..4c8830841a 100644 --- a/howto/functional.po +++ b/howto/functional.po @@ -1062,6 +1062,9 @@ msgid "" "returned only if they're requested. (The technical term for this behaviour " "is `lazy evaluation `__.)" msgstr "" +"它不會在回傳前建構一個記憶體內的串列並\\ :term:`耗盡 `\\ 所有輸入" +"的疊代器;相反地,元組只有在被請求時才會被建構並回傳。(這種行為的專業術語為" +"\\ `惰性求值 `__。)" #: ../../howto/functional.rst:732 msgid "" @@ -1186,6 +1189,9 @@ msgid "" "first iterator, then all the elements of the second, and so on, until all of " "the iterables have been :term:`exhausted`. ::" msgstr "" +":func:`itertools.chain(iterA, iterB, ...) ` 接受任意數量的可" +"疊代物件作為輸入,並回傳第一個疊代器的所有元素,接著是第二個的所有元素,依此" +"類推,直到所有可疊代物件都已\\ :term:`耗盡 `\\ 為止: ::" #: ../../howto/functional.rst:792 msgid "" @@ -1366,6 +1372,9 @@ msgid "" "corresponding element of *selectors* is true, stopping whenever either one " "is :term:`exhausted`::" msgstr "" +":func:`itertools.compress(data, selectors) ` 接受兩個疊代" +"器,只回傳 *data* 中對應 *selectors* 元素為 true 的那些元素,並在其中一個\\ :" +"term:`耗盡 `\\ 時停止: ::" #: ../../howto/functional.rst:887 msgid "" @@ -1633,6 +1642,14 @@ msgid "" "raised. If the initial value is supplied, it's used as a starting point and " "``func(initial_value, A)`` is the first calculation. ::" msgstr "" +":func:`functools.reduce(func, iter, [initial_value]) ` 會對" +"可疊代物件的所有元素累積地執行一項運算,因此無法套用於無限的可疊代物件。" +"*func* 必須是一個接受兩個元素並回傳單一值的函式。:func:`functools.reduce` 會" +"取得疊代器回傳的前兩個元素 A 和 B,並計算 ``func(A, B)``。接著它會請求第三個" +"元素 C,計算 ``func(func(A, B), C)``,並將此結果與回傳的第四個元素結合,如此" +"持續進行,直到該可疊代物件\\ :term:`耗盡 `\\ 為止。如果該可疊代物" +"件完全沒有回傳任何值,則會引發 :exc:`TypeError` 例外。如果有提供初始值,則會" +"將其作為起始點,且 ``func(initial_value, A)`` 為第一次計算。 ::" #: ../../howto/functional.rst:1040 msgid "" diff --git a/howto/logging-cookbook.po b/howto/logging-cookbook.po index 73e609df11..34ea6e0f09 100644 --- a/howto/logging-cookbook.po +++ b/howto/logging-cookbook.po @@ -2660,6 +2660,64 @@ msgid "" "finally:\n" " listener.stop()" msgstr "" +"# listener.py\n" +"import json\n" +"import logging\n" +"import logging.handlers\n" +"\n" +"import pynng\n" +"\n" +"DEFAULT_ADDR = \"tcp://localhost:13232\"\n" +"\n" +"interrupted = False\n" +"\n" +"class NNGSocketListener(logging.handlers.QueueListener):\n" +"\n" +" def __init__(self, uri, /, *handlers, **kwargs):\n" +" # Have a timeout for interruptibility, and open a\n" +" # subscriber socket\n" +" socket = pynng.Sub0(listen=uri, recv_timeout=500)\n" +" # The b'' subscription matches all topics\n" +" topics = kwargs.pop('topics', None) or b''\n" +" socket.subscribe(topics)\n" +" # We treat the socket as a queue\n" +" super().__init__(socket, *handlers, **kwargs)\n" +"\n" +" def dequeue(self, block):\n" +" data = None\n" +" # Keep looping while not interrupted and no data received over the\n" +" # socket\n" +" while not interrupted:\n" +" try:\n" +" data = self.queue.recv(block=block)\n" +" break\n" +" except pynng.Timeout:\n" +" pass\n" +" except pynng.Closed: # sometimes happens when you hit Ctrl-C\n" +" break\n" +" if data is None:\n" +" return None\n" +" # Get the logging event sent from a publisher\n" +" event = json.loads(data.decode('utf-8'))\n" +" return logging.makeLogRecord(event)\n" +"\n" +" def enqueue_sentinel(self):\n" +" # Not used in this implementation, as the socket isn't really a\n" +" # queue\n" +" pass\n" +"\n" +"logging.getLogger('pynng').propagate = False\n" +"listener = NNGSocketListener(DEFAULT_ADDR, logging.StreamHandler(), " +"topics=b'')\n" +"listener.start()\n" +"print('Press Ctrl-C to stop.')\n" +"try:\n" +" while True:\n" +" pass\n" +"except KeyboardInterrupt:\n" +" interrupted = True\n" +"finally:\n" +" listener.stop()" #: ../../howto/logging-cookbook.rst:2013 msgid "" @@ -5265,6 +5323,9 @@ msgid "" "your specific needs. With the above handler, you'd pass structured data " "using something like this::" msgstr "" +"要完全理解上述程式碼,你需要熟悉 RFC 5424,而且你的需求可能略有不同(例如如何" +"將結構化資料傳遞給日誌)。儘管如此,上述內容應該能適應你的特定需求。使用上述" +"處理器 (handler) 時,你可以像這樣傳遞結構化資料: ::" #: ../../howto/logging-cookbook.rst:3931 msgid "" diff --git a/howto/mro.po b/howto/mro.po index b08cf816ee..c013db20a7 100644 --- a/howto/mro.po +++ b/howto/mro.po @@ -32,9 +32,8 @@ msgstr "" "Python 3。" #: ../../howto/mro.rst:13 -#, fuzzy msgid "By `Michele Simionato `__." -msgstr "作者:`Michele Simionato `__。" +msgstr "作者:`Michele Simionato `__。" #: ../../howto/mro.rst:0 msgid "Abstract" @@ -361,7 +360,6 @@ msgid "" msgstr "然而,一般來說必須根據以下規則來計算合併:" #: ../../howto/mro.rst:188 -#, fuzzy msgid "" "*take the head of the first list, i.e L[B1][0]; if this head is not in the " "tail of any of the other lists, then add it to the linearization of C and " diff --git a/howto/sorting.po b/howto/sorting.po index a0c2246584..0822f50111 100644 --- a/howto/sorting.po +++ b/howto/sorting.po @@ -748,7 +748,6 @@ msgstr "" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" #: ../../howto/sorting.rst:374 -#, fuzzy msgid "" "However, note that ``<`` can fall back to using :meth:`~object.__gt__` if :" "meth:`~object.__lt__` is not implemented (see :func:`object.__lt__` for " @@ -759,7 +758,7 @@ msgstr "" "然而,請注意,當 :meth:`~object.__lt__` 沒有被實作時,``<`` 可以回退 (fall " "back) 使用 :meth:`~object.__gt__`\\ (有關技術上的細節資訊請看 :func:`object." "__lt__` )。為了避免意外發生,:pep:`8` 建議所有六種的比較函式都需要被實作。裝" -"飾器 :func:`~functools.total_ordering` 被提供用來讓任務更為簡單。" +"飾器 :deco:`~functools.total_ordering` 被提供用來讓任務更為簡單。" #: ../../howto/sorting.rst:381 msgid "" diff --git a/library/abc.po b/library/abc.po index 1be4257ee5..d119542b92 100644 --- a/library/abc.po +++ b/library/abc.po @@ -314,7 +314,6 @@ msgid "A decorator indicating abstract methods." msgstr "用於表示抽象方法的裝飾器。" #: ../../library/abc.rst:169 -#, fuzzy msgid "" "Using this decorator requires that the class's metaclass is :class:`ABCMeta` " "or is derived from it. A class that has a metaclass derived from :class:`!" @@ -325,11 +324,10 @@ msgid "" msgstr "" "類別的元類別是 :class:`ABCMeta` 或是從該類別衍生才能使用此裝飾器。一個具有衍" "生自 :class:`!ABCMeta` 之元類別的類別不可以被實例化,除非它全部的抽象方法和特" -"性均已被覆寫。抽象方法可透過任何一般的 'super' 呼叫機制來呼叫。:func:`!" +"性均已被覆寫。抽象方法可透過任何一般的 'super' 呼叫機制來呼叫。:deco:`!" "abstractmethod` 可被用於為特性和描述器宣告的抽象方法。" #: ../../library/abc.rst:176 -#, fuzzy msgid "" "Dynamically adding abstract methods to a class, or attempting to modify the " "abstraction status of a method or class once it is created, are only " @@ -339,18 +337,17 @@ msgid "" "method are not affected." msgstr "" "僅在使用 :func:`update_abstractmethods` 函式時,才能夠動態地為一個類別新增抽" -"象方法,或者嘗試在方法或類別被建立後修改其抽象狀態。:func:`!abstractmethod` " +"象方法,或者嘗試在方法或類別被建立後修改其抽象狀態。:deco:`!abstractmethod` " "只會影響使用常規繼承所衍生出的子類別;透過 ABC 的 :meth:`~ABCMeta.register` " "方法註冊的「虛擬子類別」不會受到影響。" #: ../../library/abc.rst:183 -#, fuzzy msgid "" "When :deco:`!abstractmethod` is applied in combination with other method " "descriptors, it should be applied as the innermost decorator, as shown in " "the following usage examples::" msgstr "" -"當 :func:`!abstractmethod` 與其他方法描述器 (method descriptor) 配合應用時," +"當 :deco:`!abstractmethod` 與其他方法描述器 (method descriptor) 配合應用時," "它應被當最內層的裝飾器,如以下用法範例所示: ::" #: ../../library/abc.rst:187 @@ -416,7 +413,6 @@ msgstr "" " x = property(_get_x, _set_x)" #: ../../library/abc.rst:217 -#, fuzzy msgid "" "In order to correctly interoperate with the abstract base class machinery, " "the descriptor must identify itself as abstract using :attr:`!" @@ -426,7 +422,7 @@ msgid "" msgstr "" "為了能正確地與 ABC 機制實作相互操作,描述器必須使用 :attr:`!" "__isabstractmethod__` 將自身標識為抽象的。一般來說,如果被用於組成描述器的任" -"一方法是抽象的,則此屬性應當為 ``True``。 例如,Python 的內建 :class:" +"一方法是抽象的,則此屬性應當為 ``True``。 例如,Python 的內建 :deco:" "`property` 所做的就等價於: ::" #: ../../library/abc.rst:223 @@ -462,30 +458,27 @@ msgid "The :mod:`!abc` module also supports the following legacy decorators:" msgstr ":mod:`!abc` 模組還支援下列舊式裝飾器:" #: ../../library/abc.rst:244 -#, fuzzy msgid "" "It is now possible to use :deco:`classmethod` with :deco:`abstractmethod`, " "making this decorator redundant." msgstr "" -"現在可以讓 :class:`classmethod` 配合 :func:`abstractmethod` 使用,使得此裝飾" -"器變得冗餘。" +"現在可以讓 :deco:`classmethod` 配合 :deco:`abstractmethod` 使用,使得此裝飾器" +"變得冗餘。" #: ../../library/abc.rst:248 -#, fuzzy msgid "" "A subclass of the built-in :class:`classmethod`, indicating an abstract " "classmethod. Otherwise it is similar to :deco:`abstractmethod`." msgstr "" -"內建 :func:`classmethod` 的子類別,表示為一個抽象類別方法。在其他方面它都類似" -"於 :func:`abstractmethod`。" +"內建 :class:`classmethod` 的子類別,表示為一個抽象類別方法。在其他方面它都類" +"似於 :deco:`abstractmethod`\\ 。" #: ../../library/abc.rst:251 -#, fuzzy msgid "" "This special case is deprecated, as the :deco:`classmethod` decorator is now " "correctly identified as abstract when applied to an abstract method::" msgstr "" -"這個特例已被棄用,因為現在當 :func:`classmethod` 裝飾器應用於抽象方法時已會被" +"這個特例已被棄用,因為現在當 :deco:`classmethod` 裝飾器應用於抽象方法時已會被" "正確地標識為是抽象的: ::" #: ../../library/abc.rst:255 @@ -503,30 +496,27 @@ msgstr "" " ..." #: ../../library/abc.rst:265 -#, fuzzy msgid "" "It is now possible to use :deco:`staticmethod` with :deco:`abstractmethod`, " "making this decorator redundant." msgstr "" -"現在可以讓 :class:`staticmethod` 配合 :func:`abstractmethod` 使用,使得此裝飾" +"現在可以讓 :deco:`staticmethod` 配合 :deco:`abstractmethod` 使用,使得此裝飾" "器變得冗餘。" #: ../../library/abc.rst:269 -#, fuzzy msgid "" "A subclass of the built-in :class:`staticmethod`, indicating an abstract " "staticmethod. Otherwise it is similar to :deco:`abstractmethod`." msgstr "" -"內建 :func:`staticmethod` 的子類別,表示為一個抽象靜態方法。在其他方面它都類" -"似於 :func:`abstractmethod`。" +"內建 :class:`staticmethod` 的子類別,表示為一個抽象靜態方法。在其他方面它都類" +"似於 :deco:`abstractmethod`\\ 。" #: ../../library/abc.rst:272 -#, fuzzy msgid "" "This special case is deprecated, as the :deco:`staticmethod` decorator is " "now correctly identified as abstract when applied to an abstract method::" msgstr "" -"這個特例已被棄用,因為現在當 :func:`staticmethod` 裝飾器應用於抽象方法時已會" +"這個特例已被棄用,因為現在當 :deco:`staticmethod` 裝飾器應用於抽象方法時已會" "被正確地標識為是抽象的: ::" #: ../../library/abc.rst:276 @@ -544,30 +534,27 @@ msgstr "" " ..." #: ../../library/abc.rst:285 -#, fuzzy msgid "" "It is now possible to use :deco:`property`, :deco:`property.getter`, :deco:" "`property.setter` and :deco:`property.deleter` with :deco:`abstractmethod`, " "making this decorator redundant." msgstr "" -"現在可以讓 :class:`property`、:meth:`property.getter`、:meth:`property." -"setter` 和 :meth:`property.deleter` 配合 :func:`abstractmethod` 使用,使得此" +"現在可以讓 :deco:`property`、:deco:`property.getter`、:deco:`property." +"setter` 和 :deco:`property.deleter` 配合 :deco:`abstractmethod` 使用,使得此" "裝飾器變得冗餘。" #: ../../library/abc.rst:290 -#, fuzzy msgid "" "A subclass of the built-in :class:`property`, indicating an abstract " "property." -msgstr "內建 :func:`property` 的子類別,表示為一個抽象特性。" +msgstr "內建 :class:`property` 的子類別,表示為一個抽象特性。" #: ../../library/abc.rst:293 -#, fuzzy msgid "" "This special case is deprecated, as the :deco:`property` decorator is now " "correctly identified as abstract when applied to an abstract method::" msgstr "" -"這個特例已被棄用,因為現在當 :func:`property` 裝飾器應用於抽象方法時已會被正" +"這個特例已被棄用,因為現在當 :deco:`property` 裝飾器應用於抽象方法時已會被正" "確地標識為是抽象的: ::" #: ../../library/abc.rst:297 diff --git a/library/annotationlib.po b/library/annotationlib.po index 89b082cc93..2ebbefdc74 100644 --- a/library/annotationlib.po +++ b/library/annotationlib.po @@ -344,6 +344,8 @@ msgid "" "For example, this is used to implement the :attr:`~Format.STRING` format " "for :class:`typing.TypedDict` classes created through the functional syntax:" msgstr "" +"舉例來說,這用於為透過函式語法建立的 :class:`typing.TypedDict` 類別實作 :" +"attr:`~Format.STRING` 格式:" #: ../../library/annotationlib.rst:241 msgid "" diff --git a/library/argparse.po b/library/argparse.po index ee5486f79c..e0c574b40a 100644 --- a/library/argparse.po +++ b/library/argparse.po @@ -878,7 +878,7 @@ msgstr "" msgid "" "Each line is treated as a single argument, so an empty line is read as an " "empty string (``''``)." -msgstr "" +msgstr "每一行都會被視為單一引數,因此空白行會被讀取為空字串 (``''``)。" #: ../../library/argparse.rst:448 msgid "" @@ -1655,6 +1655,8 @@ msgid "" "is a non-zero number, the count starts from that number rather than from " "zero." msgstr "" +"除非明確設定,否則 *default* 將為 ``None``。如果預設值是非零的數字,則計數會" +"從該數字開始,而不是從零開始。" #: ../../library/argparse.rst:838 msgid "" @@ -2098,6 +2100,9 @@ msgid "" "positional argument yields an empty list (``[]``). Only a non-``None`` " "*default* overrides this (so ``default=None`` still gives ``[]``)." msgstr "" +"因為 ``nargs='*'`` 會將所有提供的值收集到一個 list 中,所以缺少位置引數時會得" +"到一個空 list (``[]``)。只有非 ``None`` 的 *default* 才會覆寫此行為(因此 " +"``default=None`` 仍然會得到 ``[]``)。" #: ../../library/argparse.rst:1056 msgid "" @@ -2723,6 +2728,9 @@ msgid "" "For conflicting *option strings* rather than ``dest`` names, see " "conflict_handler_." msgstr "" +"多個引數可以共用相同的 ``dest``。預設情況下,會以命令列上最後給定的該引數的值" +"為準。可以改用 ``action='append'`` 將所有引數的值收集到一個 list 中。若衝突的" +"是 *選項字串* 而非 ``dest`` 名稱,請參閱 conflict_handler_。" #: ../../library/argparse.rst:1376 msgid "deprecated" @@ -3025,7 +3033,6 @@ msgstr "" "退出並印出錯誤及用法訊息: ::" #: ../../library/argparse.rst:1534 -#, fuzzy msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('--foo', type=int)\n" @@ -3058,12 +3065,12 @@ msgstr "" ">>> # 無效選項\n" ">>> parser.parse_args(['--bar'])\n" "usage: PROG [-h] [--foo FOO] [bar]\n" -"PROG: error: no such option: --bar\n" +"PROG: error: unrecognized arguments: --bar\n" "\n" ">>> # 錯誤引數數量\n" ">>> parser.parse_args(['spam', 'badger'])\n" "usage: PROG [-h] [--foo FOO] [bar]\n" -"PROG: error: extra arguments found: badger" +"PROG: error: unrecognized arguments: badger" #: ../../library/argparse.rst:1555 msgid "Arguments containing ``-``" @@ -3087,7 +3094,6 @@ msgstr "" "開頭: ::" #: ../../library/argparse.rst:1565 -#, fuzzy msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -3142,7 +3148,7 @@ msgstr "" ">>> # 有負數選項存在,所以 -2 是選項\n" ">>> parser.parse_args(['-2'])\n" "usage: PROG [-h] [-1 ONE] [foo]\n" -"PROG: error: no such option: -2\n" +"PROG: error: unrecognized arguments: -2\n" "\n" ">>> # 有負數選項存在,所以兩個 -1 都是選項\n" ">>> parser.parse_args(['-1', '-1'])\n" @@ -3181,6 +3187,8 @@ msgid "" "notation (``-2.5e-6``), numbers containing underscores (``-1_234.5``), and " "complex numbers (``-1.2e-3j``)." msgstr "" +"負數比對已擴充,現在也包括科學記號表示的數字(``-2.5e-6``)、包含底線的數字" +"(``-1_234.5``)以及複數(``-1.2e-3j``)。" #: ../../library/argparse.rst:1614 msgid "Argument abbreviations (prefix matching)" @@ -3499,6 +3507,9 @@ msgid "" "won't be retained. Users should give them distinct ``dest`` values to keep " "both." msgstr "" +"如果子剖析器定義了一個與父剖析器相同 ``dest`` 的引數,兩者會共用同一個命名空" +"間屬性,因此父剖析器的值不會被保留。使用者應該為它們指定不同的 ``dest`` 值," +"才能同時保留兩者。" #: ../../library/argparse.rst:1777 msgid "" @@ -4335,6 +4346,8 @@ msgid "" "Note that with this override an argument can no longer contain spaces, since " "each space-separated word becomes a separate argument." msgstr "" +"請注意,透過此覆寫,引數不能再包含空格,因為每個以空格分隔的詞都會變成一個獨" +"立的引數。" #: ../../library/argparse.rst:2226 msgid "Exiting methods" diff --git a/library/ast.po b/library/ast.po index 1105965a78..d2144bf29b 100644 --- a/library/ast.po +++ b/library/ast.po @@ -2619,7 +2619,6 @@ msgstr "" " value=Constant(value=Ellipsis))])])" #: ../../library/ast.rst:1365 -#, fuzzy msgid "" "``try`` blocks which are followed by ``except*`` clauses. The attributes are " "the same as for :class:`Try` but the :class:`ExceptHandler` nodes in " @@ -4173,14 +4172,13 @@ msgstr "" "``type_ignores`` 屬性回傳(否則它始終是一個空串列)。" #: ../../library/ast.rst:2258 -#, fuzzy msgid "" "In addition, if ``mode`` is ``'func_type'``, the input syntax is modified to " "correspond to :pep:`484` \"signature type comments\", for example ``(str, " "int) -> List[str]``." msgstr "" "此外,如果 ``mode`` 是 ``'func_type'``,則輸入語法將會依據 :pep:`484`\\ 「簽" -"名型別註解 (signature type comments)」而被修改,例如 ``(str, int) -> " +"名型別註釋 (signature type comments)」而被修改,例如 ``(str, int) -> " "List[str]``。" #: ../../library/ast.rst:2262 diff --git a/library/asyncio-dev.po b/library/asyncio-dev.po index 1e12ebce79..e7fc139cc3 100644 --- a/library/asyncio-dev.po +++ b/library/asyncio-dev.po @@ -572,6 +572,31 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"work_done = False\n" +"\n" +"async def cursor():\n" +" try:\n" +" yield 1\n" +" finally:\n" +" assert work_done\n" +"\n" +"async def rows():\n" +" global work_done\n" +" try:\n" +" yield 2\n" +" finally:\n" +" await asyncio.sleep(0.1) # 模擬一些非同步工作\n" +" work_done = True\n" +"\n" +"\n" +"async def main():\n" +" async for c in cursor():\n" +" async for r in rows():\n" +" break\n" +" break\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-dev.rst:319 msgid "For this example, we get the following output::" diff --git a/library/asyncio-eventloop.po b/library/asyncio-eventloop.po index 36ad456ad3..ceb9b2afa7 100644 --- a/library/asyncio-eventloop.po +++ b/library/asyncio-eventloop.po @@ -1752,7 +1752,6 @@ msgid "" msgstr ":meth:`socket.connect() ` 的非同步版本。" #: ../../library/asyncio-eventloop.rst:1159 -#, fuzzy msgid "" "With :class:`SelectorEventLoop`, *address* does not need to be resolved: " "for :const:`~socket.AF_INET` and :const:`~socket.AF_INET6` sockets, " @@ -1760,9 +1759,10 @@ msgid "" "calling :func:`socket.inet_pton`, and uses :meth:`loop.getaddrinfo` to " "resolve it if it is not." msgstr "" -"不再需要解析 ``address``。``sock_connect`` 將嘗試透過呼叫 :func:`socket." -"inet_pton` 檢查 *address* 是否已解析。如果沒有,將使用 :meth:`loop." -"getaddrinfo` 解析 *address*。" +"使用 :class:`SelectorEventLoop` 時,*address* 不需要事先解析:對於 :const:" +"`~socket.AF_INET` 和 :const:`~socket.AF_INET6` 這兩種 socket," +"``sock_connect`` 會先透過呼叫 :func:`socket.inet_pton` 檢查 *address* 是否已" +"經解析,如果尚未解析,則會使用 :meth:`loop.getaddrinfo` 進行解析。" #: ../../library/asyncio-eventloop.rst:1165 msgid "" @@ -1772,12 +1772,15 @@ msgid "" "getaddrinfo` first, or use :meth:`loop.create_connection`, which resolves " "the address on every platform." msgstr "" +":class:`ProactorEventLoop`\\ (Windows 上預設的事件迴圈)不會解析 " +"*address* 。主機必須已經是數值 IP 位址;傳入主機名稱將引發 :exc:" +"`OSError`\\ 。請先使用 :meth:`loop.getaddrinfo` 解析位址,或者改用 :meth:" +"`loop.create_connection`\\ ,它會在所有平台上解析位址。" #: ../../library/asyncio-eventloop.rst:1171 -#, fuzzy msgid "" "With :class:`SelectorEventLoop`, ``address`` no longer needs to be resolved." -msgstr "使用 :class:`SelectorEventLoop` 事件迴圈時,*pipe* 設置為非阻塞模式。" +msgstr "使用 :class:`SelectorEventLoop` 時,``address`` 不再需要被解析。" #: ../../library/asyncio-eventloop.rst:1177 msgid "" @@ -1897,6 +1900,8 @@ msgid "" "*pipe* is a :term:`file-like object `. See :ref:`Supported " "pipe objects ` for the objects supported as *pipe*." msgstr "" +"*pipe* 是\\ :term:`類檔案物件 `\\ 。請參閱\\ :ref:`支援的管道物" +"件 `\\ 部分,以了解可作為 *pipe* 的支援物件。" #: ../../library/asyncio-eventloop.rst:1281 msgid "" @@ -1928,9 +1933,8 @@ msgstr "" "`WriteTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" #: ../../library/asyncio-eventloop.rst:1310 -#, fuzzy msgid "Supported pipe objects" -msgstr "Server 物件" +msgstr "支援的管道物件" #: ../../library/asyncio-eventloop.rst:1311 msgid "" @@ -1940,27 +1944,32 @@ msgid "" "use :meth:`loop.run_in_executor` to read and write regular files without " "blocking the event loop." msgstr "" +"這些方法僅適用於作業系統能夠輪詢其就緒狀態,或可在其上執行重疊 I/O 的物件。磁" +"碟上的常規檔案在任何平台上都\\ **不**\\ 受支援。asyncio 中沒有非同步檔案 I/" +"O;請使用 :meth:`loop.run_in_executor` 讀寫常規檔案,以避免阻塞事件迴圈。" #: ../../library/asyncio-eventloop.rst:1317 -#, fuzzy msgid "" "On Unix, with :class:`SelectorEventLoop`, *pipe* must wrap one of the " "following:" -msgstr "使用 :class:`SelectorEventLoop` 事件迴圈時,*pipe* 設置為非阻塞模式。" +msgstr "" +"在 Unix 上,使用 :class:`SelectorEventLoop` 時,*pipe* 必須包裝以下其中一種:" #: ../../library/asyncio-eventloop.rst:1320 msgid "" "a pipe, such as an end of an :func:`os.pipe` pair or a FIFO created with :" "func:`os.mkfifo`;" msgstr "" +"管道,例如 :func:`os.pipe` 建立的其中一端,或使用 :func:`os.mkfifo` 建立的 " +"FIFO;" #: ../../library/asyncio-eventloop.rst:1322 msgid "a socket;" -msgstr "" +msgstr "socket;" #: ../../library/asyncio-eventloop.rst:1323 msgid "a character device, such as a terminal." -msgstr "" +msgstr "字元裝置,例如終端機。" #: ../../library/asyncio-eventloop.rst:1325 msgid "" @@ -1973,6 +1982,12 @@ msgid "" "created by :func:`os.pipe` are **not** opened for overlapped I/O and " "therefore cannot be used with these methods." msgstr "" +"在 Windows 上,因為只有 :class:`ProactorEventLoop` 實作了這些方法,*pipe* 必" +"須包裝一個開啟以進行重疊 I/O 的控制代碼(也就是使用 ``FILE_FLAG_OVERLAPPED`` " +"旗標建立的控制代碼),因為該控制代碼必須與一個 I/O 完成埠相關聯。未以重疊 I/" +"O 方式開啟的控制代碼將被拒絕。特別是標準串流(:data:`sys.stdin`、:data:`sys." +"stdout` 和 :data:`sys.stderr`)、主控台控制代碼,以及由 :func:`os.pipe` 建立" +"的管道,都\\ **不**\\ 是以重疊 I/O 方式開啟的,因此無法用於這些方法。" #: ../../library/asyncio-eventloop.rst:1336 msgid "" @@ -2812,6 +2827,8 @@ msgid "" "connections have finished. Previously, it returned immediately if the " "server was already closed, even if connections were still active." msgstr "" +"``wait_closed()`` 現在會等到伺服器關閉且所有活動連線都已結束才回傳。在此之" +"前,如果伺服器已經關閉,即使連線仍在活動中,它也會立即回傳。" #: ../../library/asyncio-eventloop.rst:1895 msgid "" diff --git a/library/asyncio-graph.po b/library/asyncio-graph.po index 691dff7c83..e19ab7e493 100644 --- a/library/asyncio-graph.po +++ b/library/asyncio-graph.po @@ -18,9 +18,8 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../library/asyncio-graph.rst:8 -#, fuzzy msgid "Call graph introspection" -msgstr "呼叫圖內省(Call Graph Introspection)" +msgstr "呼叫圖內省" #: ../../library/asyncio-graph.rst:10 msgid "**Source code:** :source:`Lib/asyncio/graph.py`" @@ -39,12 +38,12 @@ msgstr "" #: ../../library/asyncio-graph.rst:22 msgid ":ref:`asyncio-introspection-tools`" -msgstr "" +msgstr ":ref:`asyncio-introspection-tools`" #: ../../library/asyncio-graph.rst:23 msgid "" "Command-line tools for inspecting tasks in another running Python process." -msgstr "" +msgstr "用於檢查另一個執行中的 Python 行程中任務的命令列工具。" #: ../../library/asyncio-graph.rst:31 msgid "" diff --git a/library/asyncio-platforms.po b/library/asyncio-platforms.po index 82473b00a3..b41c3cc501 100644 --- a/library/asyncio-platforms.po +++ b/library/asyncio-platforms.po @@ -50,6 +50,9 @@ msgid "" "used with regular files. See :ref:`Supported pipe objects ` for the objects that are accepted on each platform." msgstr "" +":meth:`loop.connect_read_pipe` 和 :meth:`loop.connect_write_pipe` 不能用於常" +"規檔案。請參閱\\ :ref:`支援的管道物件 `\\ 部分,以了解" +"每個平台上可接受的物件。" #: ../../library/asyncio-platforms.rst:29 msgid "Windows" @@ -142,6 +145,9 @@ msgid "" "accept a handle opened for overlapped I/O. See :ref:`Supported pipe objects " "` for which objects are supported." msgstr "" +":meth:`loop.connect_read_pipe` 和 :meth:`loop.connect_write_pipe` 只接受開啟" +"以進行重疊 I/O 的控制代碼。請參閱\\ :ref:`支援的管道物件 `\\ 部分,以了解支援哪些物件。" #: ../../library/asyncio-platforms.rst:74 msgid "" diff --git a/library/asyncio-queue.po b/library/asyncio-queue.po index 78e49284ac..1781481a20 100644 --- a/library/asyncio-queue.po +++ b/library/asyncio-queue.po @@ -121,10 +121,9 @@ msgid "" msgstr "如果佇列內有值則立即回傳佇列中的元素,否則引發 :exc:`QueueEmpty`。" #: ../../library/asyncio-queue.rst:74 -#, fuzzy msgid "" "Raises :exc:`QueueShutDown` if the queue has been shut down and is empty." -msgstr "如果佇列已經被關閉,則引發 :exc:`QueueShutDown`。" +msgstr "如果佇列已經被關閉且為空,則引發 :exc:`QueueShutDown`。" #: ../../library/asyncio-queue.rst:79 msgid "Block until all items in the queue have been received and processed." @@ -284,14 +283,13 @@ msgstr "" "法會引發這個例外。" #: ../../library/asyncio-queue.rst:195 -#, fuzzy msgid "" "Exception raised when :meth:`~Queue.put`, :meth:`~Queue.put_nowait`, :meth:" "`~Queue.get` or :meth:`~Queue.get_nowait` is called on a queue which has " "been shut down." msgstr "" -"當佇列中條目數量已經達到它的 *maxsize* 時,呼叫 :meth:`~Queue.put_nowait` 方" -"法會引發這個例外。" +"當佇列已經被關閉時,呼叫 :meth:`~Queue.put`、:meth:`~Queue.put_nowait`、:" +"meth:`~Queue.get` 或 :meth:`~Queue.get_nowait` 方法會引發這個例外。" #: ../../library/asyncio-queue.rst:203 msgid "Examples" diff --git a/library/asyncio-stream.po b/library/asyncio-stream.po index 4b60cfc895..d877821e58 100644 --- a/library/asyncio-stream.po +++ b/library/asyncio-stream.po @@ -517,6 +517,11 @@ msgid "" "tasks from running. To prevent blocking behavior, yield to the event loop " "explicitly with ``await asyncio.sleep(0)`` (see :func:`asyncio.sleep`)." msgstr "" +"當寫入緩衝區低於最高標記位 (high watermark) 時,:meth:`drain` 會立即回傳,而" +"不會讓出控制權給事件迴圈。因此,重複呼叫 ``write()`` 後接著呼叫 ``await " +"drain()`` 的程式碼可能會阻止其他 Task 執行。為了避免阻塞行為,請明確使用 " +"``await asyncio.sleep(0)``\\ (請見 :func:`asyncio.sleep`)讓出控制權給事" +"件迴圈。" #: ../../library/asyncio-stream.rst:399 msgid "Upgrade an existing stream-based connection to TLS." diff --git a/library/asyncio-task.po b/library/asyncio-task.po index 6b545640ea..c4f7ce7526 100644 --- a/library/asyncio-task.po +++ b/library/asyncio-task.po @@ -452,6 +452,10 @@ msgid "" "class:`asyncio.TaskGroup` which keeps a strong reference to each task, " "awaits them and propagates their exceptions::" msgstr "" +"請注意,這種做法不會對這些任務執行 await,因此如果某個任務失敗,其例外將永遠" +"不會被取得;當該任務被垃圾回收時,asyncio 會記錄一則「Task exception was " +"never retrieved」訊息。為了避免這種情況,請使用 :class:`asyncio.TaskGroup`," +"它會對每個任務保留強參照、對它們執行 await,並傳播它們的例外: ::" #: ../../library/asyncio-task.rst:298 msgid "" @@ -459,6 +463,9 @@ msgid "" " for i in range(10):\n" " tg.create_task(some_coro(param=i))" msgstr "" +"async with asyncio.TaskGroup() as tg:\n" +" for i in range(10):\n" +" tg.create_task(some_coro(param=i))" #: ../../library/asyncio-task.rst:304 ../../library/asyncio-task.rst:1275 msgid "Added the *name* parameter." @@ -526,6 +533,9 @@ msgid "" "already finished, or in the process of shutting down), we will close the " "given ``coro`` and raise :exc:`RuntimeError`." msgstr "" +"在此 task group 中建立一個任務。其 signature 與 :func:`asyncio.create_task` " +"相符。如果該 task group 處於非活動狀態(例如尚未進入、已經結束,或正在關閉過" +"程中),則會關閉給定的 ``coro`` 並引發 :exc:`RuntimeError`。" #: ../../library/asyncio-task.rst:363 msgid "Close the given coroutine if the task group is not active." @@ -1194,11 +1204,11 @@ msgstr "" #: ../../library/asyncio-task.rst:860 msgid "If a timeout occurs, it cancels *aw* and raises :exc:`TimeoutError`." -msgstr "" +msgstr "如果發生逾時,它會取消 *aw* 並引發 :exc:`TimeoutError`。" #: ../../library/asyncio-task.rst:862 msgid "To prevent *aw* from being cancelled, wrap it in :func:`shield`." -msgstr "" +msgstr "為了防止 *aw* 被取消,請將它包裝在 :func:`shield` 中。" #: ../../library/asyncio-task.rst:864 msgid "" @@ -1247,6 +1257,8 @@ msgid "" "Implemented using :func:`asyncio.timeout`, a coroutine passed as *aw* is no " "longer wrapped in a :class:`Task` when *timeout* is positive." msgstr "" +"使用 :func:`asyncio.timeout` 實作後,當 *timeout* 為正值時,以 *aw* 傳入的協" +"程將不再被包裝成 :class:`Task`。" #: ../../library/asyncio-task.rst:909 msgid "Waiting primitives" @@ -1327,7 +1339,7 @@ msgstr "" msgid "" "If ``wait()`` is cancelled, the futures in *aws* are not cancelled and " "continue to run." -msgstr "" +msgstr "如果 ``wait()`` 被取消,*aws* 中的 Future 將不會被取消,且會繼續執行。" #: ../../library/asyncio-task.rst:962 msgid "Passing coroutine objects to ``wait()`` directly is forbidden." @@ -1409,6 +1421,8 @@ msgid "" "awaitables: if a timeout occurs or the iteration is cancelled, the remaining " "tasks continue to run." msgstr "" +"``as_completed()`` 不會取消執行所提供之 awaitable 的任務:如果發生逾時或疊代" +"被取消,剩餘的任務將繼續執行。" #: ../../library/asyncio-task.rst:1023 msgid "" diff --git a/library/asyncio-threading.po b/library/asyncio-threading.po index f1b502620f..db1e7523b4 100644 --- a/library/asyncio-threading.po +++ b/library/asyncio-threading.po @@ -17,7 +17,7 @@ msgstr "" #: ../../library/asyncio-threading.rst:6 msgid "asyncio and free-threaded Python" -msgstr "" +msgstr "asyncio 與自由執行緒 Python" #: ../../library/asyncio-threading.rst:8 msgid "" @@ -27,6 +27,10 @@ msgid "" "off-loading CPU-bound work to a thread or process pool, but that is still " "limited by the :term:`global interpreter lock` in CPython." msgstr "" +"asyncio 使用事件迴圈作為排程器,藉由在多個任務之間切換來實現高效率的並行性," +"並允許非阻塞的 I/O 操作。這讓 I/O 密集型的使用情境有更好的效能。它也允許將 " +"CPU 密集型的工作卸載給執行緒池或行程池,但這仍然受限於 CPython 中的\\ :term:`" +"全域直譯器鎖 `。" #: ../../library/asyncio-threading.rst:15 msgid "" @@ -35,6 +39,9 @@ msgid "" "asyncio can now take advantage of multiple CPU cores without the limitations " "imposed by the GIL." msgstr "" +"然而,在\\ :ref:`自由執行緒 Python `\\ 中,GIL 會" +"被停用,Python 能夠執行真正的多執行緒程式碼。這代表 asyncio 現在可以在不受 " +"GIL 限制的情況下,充分利用多個 CPU 核心。" #: ../../library/asyncio-threading.rst:20 msgid "" @@ -42,6 +49,8 @@ msgid "" "and the implementation of asyncio is safe to use in a multi-threaded " "environment." msgstr "" +"自 Python 3.14 起,asyncio 提供了對自由執行緒 Python 的完整支援,且 asyncio " +"的實作在多執行緒環境中可安全使用。" #: ../../library/asyncio-threading.rst:24 msgid "" @@ -54,6 +63,12 @@ msgid "" "multiple CPU cores. It is also useful when you need to run blocking or CPU-" "bound code from an asyncio application." msgstr "" +"在單一核心上運行的單一事件迴圈可以同時處理許多個連線,但用來處理每個連線的 " +"Python 程式碼仍然是依序執行的。一旦每個請求所需的運算量變得不小,這種處理方式" +"就會成為瓶頸,單一核心也就無法再負荷。此時將 asyncio 與執行緒結合會特別有用:" +"透過每個執行緒各自運行一個事件迴圈,不同請求的處理便能在多個 CPU 核心上平行執" +"行。當你需要在 asyncio 應用程式中執行阻塞或 CPU 密集型程式碼時,這種做法也很" +"有幫助。" #: ../../library/asyncio-threading.rst:37 msgid "" @@ -63,10 +78,14 @@ msgid "" "under free-threaded Python, together with benchmarks of the resulting " "improvements." msgstr "" +"`Scaling asyncio on Free-Threaded Python `__,這是 Kumar Aditya 撰寫的部落格文" +"章,說明了讓 asyncio 在自由執行緒 Python 下保持安全與高效的內部變更,並附上改" +"善成果的效能基準測試。" #: ../../library/asyncio-threading.rst:45 msgid "Thread safety considerations" -msgstr "" +msgstr "執行緒安全考量" #: ../../library/asyncio-threading.rst:47 msgid "" @@ -74,6 +93,8 @@ msgid "" "environment, there are still some considerations to keep in mind when using " "asyncio with threads:" msgstr "" +"雖然 asyncio 在自由執行緒 Python 環境中被設計為執行緒安全,但在搭配執行緒使" +"用 asyncio 時,仍有一些注意事項:" #: ../../library/asyncio-threading.rst:51 msgid "" @@ -81,12 +102,16 @@ msgid "" "be shared across threads. This ensures that the event loop can manage its " "own tasks and callbacks without interference from other threads." msgstr "" +"**事件迴圈**:每個執行緒都應該有自己的事件迴圈,且不應在多個執行緒之間共用。" +"這可以確保事件迴圈能夠管理自己的任務和回呼,而不受其他執行緒的干擾。" #: ../../library/asyncio-threading.rst:56 msgid "" "**Task management**: Tasks and futures created in one thread should not be " "awaited or manipulated from another thread." msgstr "" +"**任務管理**:在一個執行緒中建立的任務和 Future 不應該在另一個執行緒中被等待" +"或操作。" #: ../../library/asyncio-threading.rst:59 msgid "" @@ -96,6 +121,10 @@ msgid "" "loop from another thread. If you need to call a callback from a different " "thread, you can use :meth:`loop.call_soon_threadsafe` to schedule it safely." msgstr "" +"**執行緒安全的 API**:從多個執行緒與 asyncio 互動時,使用 asyncio 提供的執行" +"緒安全 API 相當重要,例如使用 :func:`asyncio.run_coroutine_threadsafe` 從另一" +"個執行緒向事件迴圈提交協程。如果你需要從不同的執行緒呼叫回呼函式,可以使用 :" +"meth:`loop.call_soon_threadsafe` 來安全地排程該回呼。" #: ../../library/asyncio-threading.rst:66 msgid "" @@ -105,10 +134,13 @@ msgid "" "should use the synchronization primitives from the :mod:`threading` module " "instead." msgstr "" +"**同步**:asyncio 提供的同步原語(例如 :class:`asyncio.Lock` 和 :class:" +"`asyncio.Event`)並不是設計來跨執行緒使用的。如果你需要在執行緒之間進行同步," +"應該改用 :mod:`threading` 模組提供的同步原語。" #: ../../library/asyncio-threading.rst:74 msgid "Using asyncio with threads" -msgstr "" +msgstr "搭配執行緒使用 asyncio" #: ../../library/asyncio-threading.rst:76 msgid "" @@ -117,10 +149,13 @@ msgid "" "thread can run its own event loop, and tasks can be scheduled on those loops " "independently." msgstr "" +"asyncio 支援每個執行緒各自運行一個事件迴圈,這讓你可以在自由執行緒 Python 環" +"境中充分利用多個 CPU 核心。每個執行緒都可以運行自己的事件迴圈,且任務可以獨立" +"地被排程到這些事件迴圈上。" #: ../../library/asyncio-threading.rst:81 msgid "Here's an example of how to use asyncio with threads::" -msgstr "" +msgstr "以下是如何搭配執行緒使用 asyncio 的範例: ::" #: ../../library/asyncio-threading.rst:83 msgid "" @@ -144,6 +179,25 @@ msgid "" "for t in threads:\n" " t.join()" msgstr "" +"import asyncio\n" +"import threading\n" +"\n" +"async def worker(name: str) -> None:\n" +" print(f\"Worker {name} starting\")\n" +" await asyncio.sleep(1)\n" +" print(f\"Worker {name} done\")\n" +"\n" +"def run_loop(name: str) -> None:\n" +" asyncio.run(worker(name))\n" +"\n" +"threads = [\n" +" threading.Thread(target=run_loop, args=(f\"T{i}\",))\n" +" for i in range(4)\n" +"]\n" +"for t in threads:\n" +" t.start()\n" +"for t in threads:\n" +" t.join()" #: ../../library/asyncio-threading.rst:103 msgid "" @@ -151,10 +205,13 @@ msgid "" "run` and runs a coroutine on it. The threads execute concurrently, and in a " "free-threaded build they can run on separate CPU cores in parallel." msgstr "" +"在這個範例中,每個執行緒都使用 :func:`asyncio.run` 建立自己的事件迴圈,並在其" +"上運行一個協程。這些執行緒會並行執行,而在自由執行緒建置版本中,它們可以在不" +"同的 CPU 核心上平行運行。" #: ../../library/asyncio-threading.rst:110 msgid "Producer/consumer across threads" -msgstr "" +msgstr "跨執行緒的生產者/消費者" #: ../../library/asyncio-threading.rst:112 msgid "" @@ -163,6 +220,9 @@ msgid "" "`queue.Queue` rather than :class:`asyncio.Queue`, which is only safe within " "a single event loop.::" msgstr "" +"當一個普通(非 asyncio)的執行緒需要將工作交給在另一個執行緒中運行的 asyncio " +"事件迴圈時,應該使用像 :class:`queue.Queue` 這樣的執行緒安全原語,而不是只在" +"單一事件迴圈中才安全的 :class:`asyncio.Queue`。 ::" #: ../../library/asyncio-threading.rst:117 msgid "" @@ -196,6 +256,35 @@ msgid "" "producer(q)\n" "consumer_thread.join()" msgstr "" +"import asyncio\n" +"import queue\n" +"import threading\n" +"\n" +"def producer(q: queue.Queue[int]) -> None:\n" +" for i in range(5):\n" +" print(f\"Producing {i}\")\n" +" q.put(i)\n" +" q.shutdown()\n" +"\n" +"async def consumer(q: queue.Queue[int]) -> None:\n" +" while True:\n" +" try:\n" +" item = q.get_nowait()\n" +" except queue.Empty:\n" +" await asyncio.sleep(0.1)\n" +" continue\n" +" except queue.ShutDown:\n" +" break\n" +" print(f\"Consumed {item}\")\n" +" await asyncio.sleep(item)\n" +"\n" +"q: queue.Queue[int] = queue.Queue()\n" +"consumer_thread = threading.Thread(\n" +" target=lambda: asyncio.run(consumer(q))\n" +")\n" +"consumer_thread.start()\n" +"producer(q)\n" +"consumer_thread.join()" #: ../../library/asyncio-threading.rst:147 msgid "" @@ -206,3 +295,7 @@ msgid "" "subsequent :meth:`~queue.Queue.get_nowait` calls to raise :exc:`queue." "ShutDown` so the consumer can exit cleanly." msgstr "" +"生產者運行在主執行緒上,而消費者則在自己執行緒中的事件迴圈裡運行,但兩者能透" +"過 ``queue.Queue`` 安全地通訊。當佇列為空時,消費者會短暫休眠後再重試。當生產" +"者完成時,它會呼叫 :meth:`~queue.Queue.shutdown`,這會使後續的 :meth:`~queue." +"Queue.get_nowait` 呼叫引發 :exc:`queue.ShutDown`,讓消費者能夠乾淨地結束。" diff --git a/library/asyncio-tools.po b/library/asyncio-tools.po index 86b813fdcd..0d22ddc4ce 100644 --- a/library/asyncio-tools.po +++ b/library/asyncio-tools.po @@ -19,11 +19,11 @@ msgstr "" #: ../../library/asyncio-tools.rst:7 msgid "Command-line introspection tools" -msgstr "" +msgstr "命令列內省工具" #: ../../library/asyncio-tools.rst:9 msgid "**Source code:** :source:`Lib/asyncio/tools.py`" -msgstr "" +msgstr "**原始碼:**\\ :source:`Lib/asyncio/tools.py`" #: ../../library/asyncio-tools.rst:13 msgid "" @@ -32,16 +32,21 @@ msgid "" "without modifying it or restarting it. The :mod:`!asyncio.tools` submodule " "implements this interface." msgstr "" +":mod:`!asyncio` 模組可以透過 ``python -m asyncio`` 作為指令碼叫用,以檢查另一" +"個執行中 Python 行程的任務圖,而不需修改或重新啟動該行程。:mod:`!asyncio." +"tools` 子模組實作了此介面。" #: ../../library/asyncio-tools.rst:18 msgid "The following commands inspect the process identified by ``PID``:" -msgstr "" +msgstr "以下指令用於檢查以 ``PID`` 識別的行程:" #: ../../library/asyncio-tools.rst:20 msgid "" "$ python -m asyncio pstree PID\n" "$ python -m asyncio ps PID" msgstr "" +"$ python -m asyncio pstree [--retries N] PID\n" +"$ python -m asyncio ps [--retries N] PID" #: ../../library/asyncio-tools.rst:25 msgid "" @@ -50,26 +55,30 @@ msgid "" "inspect another process. See the :ref:`permission requirements ` for details." msgstr "" +"這些指令會讀取目標行程的狀態,而不會在其中執行任何程式碼。它們僅在受支援的平" +"台上可用,且可能需要權限才能檢查其他行程。詳情請參閱\\ :ref:`permission-" +"requirements `。" #: ../../library/asyncio-tools.rst:31 msgid ":ref:`asyncio-graph`" -msgstr "" +msgstr ":ref:`asyncio-graph`" #: ../../library/asyncio-tools.rst:32 msgid "" "Programmatic APIs for inspecting the async call graph of a task or future in " "the current process." -msgstr "" +msgstr "用於檢查目前行程中某個任務或 future 的非同步呼叫圖的程式化 API。" #: ../../library/asyncio-tools.rst:35 msgid "" "The command examples below use this program, which creates a task hierarchy " "suitable for inspection and prints its process ID:" msgstr "" +"以下指令範例使用這個程式,它會建立一個適合檢查的任務階層,並印出其行程 ID:" #: ../../library/asyncio-tools.rst:38 msgid "example.py" -msgstr "" +msgstr "example.py" #: ../../library/asyncio-tools.rst:38 msgid "" @@ -99,16 +108,43 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"import os\n" +"\n" +"async def play(track):\n" +" await asyncio.sleep(3600)\n" +" print(f\"🎵 Finished: {track}\")\n" +"\n" +"async def album(name, tracks):\n" +" async with asyncio.TaskGroup() as tg:\n" +" for track in tracks:\n" +" tg.create_task(play(track), name=track)\n" +"\n" +"async def main():\n" +" print(f\"PID: {os.getpid()}\")\n" +" async with asyncio.TaskGroup() as tg:\n" +" tg.create_task(\n" +" album(\"Sundowning\", [\"TNDNBTG\", \"Levitate\"]),\n" +" name=\"Sundowning\",\n" +" )\n" +" tg.create_task(\n" +" album(\"TMBTE\", [\"DYWTYLM\", \"Aqua Regia\"]),\n" +" name=\"TMBTE\",\n" +" )\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-tools.rst:67 msgid "Run the program in one terminal and leave it running:" -msgstr "" +msgstr "在一個終端機中執行此程式,並讓它持續執行:" #: ../../library/asyncio-tools.rst:69 msgid "" "$ python example.py\n" "PID: 12345" msgstr "" +"$ python example.py\n" +"PID: 12345" #: ../../library/asyncio-tools.rst:74 msgid "" @@ -116,10 +152,12 @@ msgid "" "Thread IDs, task IDs, file paths, and line numbers vary between runs and " "source layouts." msgstr "" +"然後在另一個終端機中,將印出的行程 ID 傳給這些指令。執行緒 ID、任務 ID、檔案" +"路徑和行號會因每次執行和原始碼配置的不同而有所差異。" #: ../../library/asyncio-tools.rst:81 msgid "Command-line options" -msgstr "" +msgstr "命令列選項" #: ../../library/asyncio-tools.rst:85 msgid "" @@ -129,6 +167,9 @@ msgid "" "task hierarchy is blocked and where in its coroutine stack execution has " "paused:" msgstr "" +"以樹狀結構顯示任務與協程之間的關係。每個任務都會顯示其完整的協程堆疊,並巢狀" +"顯示在正在等待它的任務(如果有的話)之下。此子指令有助於快速找出任務階層中哪" +"個分支被阻塞,以及其協程堆疊中執行暫停的位置:" #: ../../library/asyncio-tools.rst:91 msgid "" @@ -162,6 +203,35 @@ msgid "" " └── play example.py:4\n" " └── sleep Lib/asyncio/tasks.py:702" msgstr "" +"$ python -m asyncio pstree 12345\n" +"└── (T) Task-1\n" +" └── main example.py:12\n" +" └── TaskGroup.__aexit__ Lib/asyncio/taskgroups.py:75\n" +" └── TaskGroup._aexit Lib/asyncio/taskgroups.py:124\n" +" ├── (T) Sundowning\n" +" │ └── album example.py:7\n" +" │ └── TaskGroup.__aexit__ Lib/asyncio/taskgroups." +"py:75\n" +" │ └── TaskGroup._aexit Lib/asyncio/taskgroups." +"py:124\n" +" │ ├── (T) TNDNBTG\n" +" │ │ └── play example.py:4\n" +" │ │ └── sleep Lib/asyncio/tasks.py:702\n" +" │ └── (T) Levitate\n" +" │ └── play example.py:4\n" +" │ └── sleep Lib/asyncio/tasks.py:702\n" +" └── (T) TMBTE\n" +" └── album example.py:7\n" +" └── TaskGroup.__aexit__ Lib/asyncio/taskgroups." +"py:75\n" +" └── TaskGroup._aexit Lib/asyncio/taskgroups." +"py:124\n" +" ├── (T) DYWTYLM\n" +" │ └── play example.py:4\n" +" │ └── sleep Lib/asyncio/tasks.py:702\n" +" └── (T) Aqua Regia\n" +" └── play example.py:4\n" +" └── sleep Lib/asyncio/tasks.py:702" #: ../../library/asyncio-tools.rst:119 msgid "" @@ -169,6 +239,8 @@ msgid "" "printing a tree. A cycle in the await graph is unusual and typically " "indicates a programming error:" msgstr "" +"如果等待圖中包含循環,``pstree`` 會回報錯誤,而不會印出樹狀圖。等待圖中出現循" +"環的情況並不常見,通常代表程式有問題:" #: ../../library/asyncio-tools.rst:123 msgid "" @@ -177,6 +249,10 @@ msgid "" "\n" "cycle: Task-2 → Task-3 → Task-2" msgstr "" +"$ python -m asyncio pstree 12345\n" +"ERROR: await-graph contains cycles - cannot print a tree!\n" +"\n" +"cycle: Task-2 → Task-3 → Task-2" #: ../../library/asyncio-tools.rst:132 msgid "" @@ -184,12 +260,15 @@ msgid "" "shows the event-loop thread ID, task ID and name, coroutine stack, and the " "awaiting task's stack, name, and ID, if any." msgstr "" +"顯示行程 *PID* 中所有擱置中任務的平面表格。每一列會顯示事件迴圈的執行緒 ID、" +"任務 ID 與名稱、協程堆疊,以及等待該任務的任務之堆疊、名稱與 ID(如果有的" +"話)。" #: ../../library/asyncio-tools.rst:136 msgid "" "This subcommand prints all tasks regardless of whether the await graph " "contains cycles:" -msgstr "" +msgstr "無論等待圖中是否包含循環,此子指令都會印出所有任務:" #: ../../library/asyncio-tools.rst:139 msgid "" @@ -221,3 +300,30 @@ msgid "" "play TaskGroup._aexit -> TaskGroup." "__aexit__ -> album TMBTE 0x10a439d70" msgstr "" +"$ python -m asyncio ps 12345\n" +"tid task id task name coroutine " +"stack awaiter " +"chain awaiter name awaiter id\n" +"------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n" +"18445801 0x10a456060 Task-1 TaskGroup._aexit -> " +"TaskGroup.__aexit__ -> " +"main " +"0x0\n" +"18445801 0x10a439f60 Sundowning TaskGroup._aexit -> " +"TaskGroup.__aexit__ -> album TaskGroup._aexit -> TaskGroup.__aexit__ -> " +"main Task-1 0x10a456060\n" +"18445801 0x10a439d70 TMBTE TaskGroup._aexit -> " +"TaskGroup.__aexit__ -> album TaskGroup._aexit -> TaskGroup.__aexit__ -> " +"main Task-1 0x10a456060\n" +"18445801 0x10a2a3a80 TNDNBTG sleep -> " +"play TaskGroup._aexit -> TaskGroup." +"__aexit__ -> album Sundowning 0x10a439f60\n" +"18445801 0x10a2a38a0 Levitate sleep -> " +"play TaskGroup._aexit -> TaskGroup." +"__aexit__ -> album Sundowning 0x10a439f60\n" +"18445801 0x10a2d7150 DYWTYLM sleep -> " +"play TaskGroup._aexit -> TaskGroup." +"__aexit__ -> album TMBTE 0x10a439d70\n" +"18445801 0x10a6bdaa0 Aqua Regia sleep -> " +"play TaskGroup._aexit -> TaskGroup." +"__aexit__ -> album TMBTE 0x10a439d70" diff --git a/library/asyncio.po b/library/asyncio.po index 4c730a85f0..68accf02a6 100644 --- a/library/asyncio.po +++ b/library/asyncio.po @@ -27,7 +27,7 @@ msgstr "高階 API" #: ../../library/asyncio.rst:119 msgid "Introspection APIs" -msgstr "" +msgstr "內省 API" #: ../../library/asyncio.rst:126 msgid "Low-level APIs" @@ -126,18 +126,20 @@ msgstr ":ref:`同步 `\\ 並行程式碼;" #: ../../library/asyncio.rst:50 msgid "For **introspection**, asyncio provides APIs and tools for:" -msgstr "" +msgstr "為了\\ **內省**,asyncio 提供了下列 API 與工具:" #: ../../library/asyncio.rst:52 msgid "" "inspecting the :ref:`async call graph ` of tasks and futures;" -msgstr "" +msgstr "檢查任務與 future 的\\ :ref:`非同步呼叫圖 `;" #: ../../library/asyncio.rst:54 msgid "" "inspecting tasks in another running Python process with :ref:`command-line " "tools `;" msgstr "" +"使用\\ :ref:`命令列工具 `\\ 檢查另一個執行中的 " +"Python 行程中的任務;" #: ../../library/asyncio.rst:57 msgid "" diff --git a/library/atexit.po b/library/atexit.po index 914402105f..72507b0b73 100644 --- a/library/atexit.po +++ b/library/atexit.po @@ -30,9 +30,12 @@ msgid "" "called or the main module's execution completes) or, more generally, upon :" "term:`interpreter shutdown`." msgstr "" +":mod:`!atexit` 模組定義了用於註冊和註銷\\ :dfn:`退出處理函式`\\ 的函式:這些" +"函式會在「退出時」自動執行,也就是在程式正常終止時(例如呼叫 :func:`sys." +"exit` 或主模組執行完成時),或更廣義地說,在\\ :term:`直譯器關閉 " +"`\\ 時。" #: ../../library/atexit.rst:18 -#, fuzzy msgid "" "At exit, all registered exit handlers are called in the *reverse* order in " "which they were registered. If you register ``A``, ``B``, and ``C``, at " @@ -40,12 +43,12 @@ msgid "" "The assumption is that lower level modules will normally be imported before " "higher level modules and thus must be cleaned up later." msgstr "" -"在程式正常終止時(例如呼叫 :func:`sys.exit` 或主要模組執行完成),所有已註冊" -"函式都會依照後進先出的順序呼叫。這邊做的假設是較低階的模組通常會在較高階模組" -"之前被引入,因此較低階模組必須在比較後面才被清理。" +"退出時,所有已註冊的退出處理函式都會按照註冊順序的\\ *反序*\\ 被呼叫。如果你" +"註冊了 ``A``、``B`` 和 ``C``,則在直譯器關閉時,它們會按照 ``C``、``B``、" +"``A`` 的順序執行。這邊做的假設是較低階的模組通常會在較高階模組之前被引入,因" +"此較低階模組必須在比較後面才被清理。" #: ../../library/atexit.rst:25 -#, fuzzy msgid "" "If an exception is raised during execution of an exit handler, a traceback " "is printed (unless :exc:`SystemExit` is raised) and the exception " @@ -64,16 +67,19 @@ msgid "" "C API :c:func:`Py_EndInterpreter`). Registration functions in this module " "only affect the interpreter they are called from." msgstr "" +"在使用多個直譯器的程式中,每個直譯器都有自己的退出處理函式堆疊,這些函式會在" +"該直譯器關閉時執行(例如透過 :meth:`concurrent.interpreters.Interpreter." +"close` 或 C API :c:func:`Py_EndInterpreter`)。此模組中的註冊函式只會影響呼叫" +"它們的那個直譯器。" #: ../../library/atexit.rst:37 -#, fuzzy msgid "" "**Note:** Exit handlers are not called when the program is killed by a " "signal not handled by Python, when a Python fatal internal error is " "detected, or when :func:`os._exit` is called." msgstr "" -"**注意:**\\ 當程式被一個不是來自 Python 的訊號終止、偵測到有 Python 嚴重內部" -"錯誤時或者 :func:`os._exit` 被呼叫時,透過此模組註冊的函式就不會被呼叫。" +"**注意:**\\ 當程式被一個 Python 未處理的訊號終止、偵測到 Python 發生嚴重內部" +"錯誤,或者 :func:`os._exit` 被呼叫時,退出處理函式就不會被呼叫。" #: ../../library/atexit.rst:41 msgid "" @@ -87,9 +93,11 @@ msgid "" "that other exit handlers may still run arbitrary Python code after you clean " "up. Such code should succeed or fail with an exception, rather than crash." msgstr "" +"在撰寫退出處理函式時,特別是在 C API 擴充套件中,請記住其他退出處理函式可能會" +"在你清理完成之後,仍然執行任意的 Python 程式碼。這樣的程式碼應該成功執行或以" +"例外表示失敗,而不是造成崩潰 (crash)。" #: ../../library/atexit.rst:50 -#, fuzzy msgid "" "Attempts to start a new thread or :func:`os.fork` a new process in an exit " "handler now leads to :exc:`RuntimeError`. Previously, this could cause race " @@ -97,29 +105,27 @@ msgid "" "while internal :mod:`threading` routines or the new process try to use that " "state, which could lead to crashes rather than clean shutdown." msgstr "" -"啟動新執行緒或從已註冊函式呼叫 :func:`os.fork` 可能會導致 Python 主要 " -"runtime 執行緒釋放執行緒狀態,而內部 :mod:`threading` 例程或新行程嘗試使用該" -"狀態所形成的競態條件 (race condition)。這可能會導致崩潰 (crash) 而不是完整關" -"閉中止。" +"在退出處理函式中嘗試啟動新執行緒或以 :func:`os.fork` 建立新行程,現在會導致" +"\\ :exc:`RuntimeError`。在此之前,這可能會在 Python 主要 runtime 執行緒釋放執" +"行緒狀態的同時,內部 :mod:`threading` 例程或新行程嘗試使用該狀態,兩者間形成" +"競態條件 (race condition),進而導致崩潰 (crash) 而非乾淨的關閉。" #: ../../library/atexit.rst:58 -#, fuzzy msgid "" "When used with subinterpreters, registered functions are local to the " "interpreter they were registered in." msgstr "" -"當與 C-API 子直譯器 (subinterpreter) 一起使用時,已註冊函式對於它們所註冊的直" -"譯器來說是區域的 (local)。" +"當與子直譯器 (subinterpreter) 一起使用時,已註冊函式對於它們所註冊的直譯器來" +"說是區域的 (local)。" #: ../../library/atexit.rst:64 -#, fuzzy msgid "" "Register *func* as an exit handler. Any optional arguments that are to be " "passed to *func* must be passed as arguments to :func:`register`. It is " "possible to register the same function and arguments more than once." msgstr "" -"將 *func* 註冊為要在終止時執行的函式。任何要傳遞給 *func* 的可選引數都必須作" -"為引數傳遞給 :func:`register`。可以多次註冊相同的函式和引數。" +"將 *func* 註冊為一個退出處理函式。任何要傳遞給 *func* 的可選引數都必須作為引" +"數傳遞給 :func:`register`。可以多次註冊相同的函式和引數。" #: ../../library/atexit.rst:69 msgid "" @@ -128,7 +134,6 @@ msgid "" msgstr "該函式回傳 *func*,這使得可以將其作為裝飾器使用。" #: ../../library/atexit.rst:74 -#, fuzzy msgid "" "Remove *func* from the list of exit handlers. :func:`unregister` silently " "does nothing if *func* was not previously registered. If *func* has been " @@ -137,10 +142,10 @@ msgid "" "internally during unregistration, so function references do not need to have " "matching identities." msgstr "" -"從在直譯器中止時會執行之函式串列中刪除 *func*。如果 *func* 先前未被註冊,則 :" -"func:`unregister` 不會執行任何操作。如果 *func* 已被註冊多次,則該函式在 :" -"mod:`!atexit` 呼叫堆疊 (call stack) 中的所有存在都會被刪除。會在註銷期間於內" -"部使用相等性比較 (``==``),因此函式參照不需要具有匹配的識別性。" +"從退出處理函式串列中移除 *func*。如果 *func* 先前未被註冊,則 :func:" +"`unregister` 不會執行任何操作。如果 *func* 已被註冊多次,則該函式在 :mod:`!" +"atexit` 呼叫堆疊 (call stack) 中的所有存在都會被刪除。會在註銷期間於內部使用" +"相等性比較 (``==``),因此函式參照不需要具有匹配的識別性。" #: ../../library/atexit.rst:84 msgid "Module :mod:`readline`" diff --git a/library/bisect.po b/library/bisect.po index 3bbfd69e34..bc9d422cac 100644 --- a/library/bisect.po +++ b/library/bisect.po @@ -209,7 +209,6 @@ msgstr "" "導 (dominate)。" #: ../../library/bisect.rst:131 -#, fuzzy msgid "" "The search functions are stateless and discard key function results after " "they are used. Consequently, if the search functions are used in a loop, " @@ -221,7 +220,7 @@ msgid "" msgstr "" "搜尋函式為無狀態的 (stateless),且鍵函式會在使用過後被丟棄。因此,如果搜尋函" "式被使用於迴圈當中,鍵函式會不斷被重複呼叫於相同的 list 元素。如果鍵函式執行" -"速度不快,請考慮將其以 :py:func:`functools.cache` 包裝起來以減少重複的計算。" +"速度不快,請考慮將其以 :py:deco:`functools.cache` 包裝起來以減少重複的計算。" "另外,也可以透過搜尋預先計算好的鍵列表 (array of precomputed keys) 來定位插入" "點(如下方範例所示)。" diff --git a/library/calendar.po b/library/calendar.po index 66f218e591..de285f97cd 100644 --- a/library/calendar.po +++ b/library/calendar.po @@ -534,11 +534,10 @@ msgstr "" "``31``) 是週幾(``0`` 是星期一)。" #: ../../library/calendar.rst:402 -#, fuzzy msgid "" "Return a header containing abbreviated weekday names. *width* specifies the " "width in characters for one weekday." -msgstr "回傳包含一週每一天的名稱縮寫的標題。*n* 指定每一天的字元寬度。" +msgstr "回傳包含一週每一天的名稱縮寫的標題。*width* 指定每一天的字元寬度。" #: ../../library/calendar.rst:408 msgid "" diff --git a/library/codecs.po b/library/codecs.po index 221eb84069..d87b35e4b3 100644 --- a/library/codecs.po +++ b/library/codecs.po @@ -2392,6 +2392,8 @@ msgid "" "This codec builds on ``punycode``, whose algorithms scale poorly, so limit " "the length of untrusted input." msgstr "" +"此 codec 是建立在 ``punycode`` 之上,而 ``punycode`` 的演算法的效能會隨輸入變" +"大而急遽變差,因此請限制不受信任輸入的長度。" #: ../../library/codecs.rst:1393 msgid "mbcs" @@ -2436,6 +2438,8 @@ msgid "" "The decoding and encoding algorithms scale poorly, so limit the length of " "untrusted input." msgstr "" +"此解碼和編碼演算法的效能會隨輸入變大而急遽變差,因此請限制不受信任輸入的長" +"度。" #: ../../library/codecs.rst:1417 msgid "raw_unicode_escape" @@ -2768,6 +2772,8 @@ msgid "" "This module builds on ``punycode``, whose algorithms scale poorly, so limit " "the length of untrusted input." msgstr "" +"此模組是建立在 ``punycode`` 之上,而 ``punycode`` 的演算法的效能會隨輸入變大" +"而急遽變差,因此請限制不受信任輸入的長度。" #: ../../library/codecs.rst:1641 msgid "" diff --git a/library/collections.abc.po b/library/collections.abc.po index f5d30db6dd..81b4d1bf5f 100644 --- a/library/collections.abc.po +++ b/library/collections.abc.po @@ -822,6 +822,10 @@ msgid "" "using mixins, inherit from both :class:`Set` and :class:`Hashable`, then " "define ``__hash__ = Set._hash``." msgstr "" +":class:`Set` mixin 提供了 :meth:`!_hash` 方法來計算集合的雜湊值;然而,由於並" +"非所有集合都是\\ :term:`可雜湊的 `\\ 或不可變的,因此並未定義 :" +"meth:`~object.__hash__`。若要使用 mixin 為集合加入可雜湊性,請同時繼承 :" +"class:`Set` 和 :class:`Hashable`,然後定義 ``__hash__ = Set._hash``。" #: ../../library/collections.abc.rst:467 msgid "" diff --git a/library/collections.po b/library/collections.po index d92806d0d5..409a2432ca 100644 --- a/library/collections.po +++ b/library/collections.po @@ -1057,7 +1057,6 @@ msgid "" msgstr "" #: ../../library/collections.rst:686 -#, fuzzy msgid "" "A `round-robin scheduler `_ can be implemented with input iterators stored in a :" @@ -1068,9 +1067,9 @@ msgid "" msgstr "" "一個\\ `輪詢調度器 `_\\ 可以透過在 :class:`deque` 中放入 iterator 來實現,值自" -"目前 iterator 的位置 0 取出,如果 iterator 已經消耗完畢就用 :meth:`~deque." -"popleft` 將其從佇列中移除,否則利用 :meth:`~deque.rotate` 來將其移至佇列尾" -"端: ::" +"目前 iterator 的位置 0 取出,如果該 iterator 已\\ :term:`耗盡 `," +"就用 :meth:`~deque.popleft` 將其從佇列中移除,否則利用 :meth:`~deque.rotate` " +"來將其移至佇列尾端: ::" #: ../../library/collections.rst:693 msgid "" @@ -1975,12 +1974,11 @@ msgid "" msgstr "" #: ../../library/collections.rst:1226 -#, fuzzy msgid "" "An :class:`OrderedDict` would also be useful for implementing variants of :" "deco:`functools.lru_cache`:" msgstr "" -":class:`OrderedDict` 在實現一個 :func:`functools.lru_cache` 的變形版本時也非" +":class:`OrderedDict` 在實現一個 :deco:`functools.lru_cache` 的變形版本時也非" "常有用:" #: ../../library/collections.rst:1229 diff --git a/library/colorsys.po b/library/colorsys.po index 750bf72ba4..2dce8b5cfb 100644 --- a/library/colorsys.po +++ b/library/colorsys.po @@ -45,14 +45,13 @@ msgstr "" "座標均可以為正數或負數。在所有其他空間中,座標值均為 0 和 1 之間。" #: ../../library/colorsys.rst:23 -#, fuzzy msgid "" "More information about color spaces can be found at https://www.poynton.ca/" "pdf/ColourFAQ.pdf and https://www.cambridgeincolour.com/tutorials/color-" "spaces.htm." msgstr "" -"有關色彩空間的更多資訊請見 https://poynton.ca/ColorFAQ.html 和 https://www." -"cambridgeincolour.com/tutorials/color-spaces.htm。" +"有關色彩空間的更多資訊請見 https://www.poynton.ca/pdf/ColourFAQ.pdf 和 " +"https://www.cambridgeincolour.com/tutorials/color-spaces.htm。" #: ../../library/colorsys.rst:27 msgid "The :mod:`!colorsys` module defines the following functions:" diff --git a/library/compression.zstd.po b/library/compression.zstd.po index 9990a39f58..62c4db6e34 100644 --- a/library/compression.zstd.po +++ b/library/compression.zstd.po @@ -448,6 +448,8 @@ msgid "" "`EOFError`. Any data found after the end of the frame is ignored and saved " "in the :attr:`~.unused_data` attribute." msgstr "" +"在一個 frame 結束後嘗試解壓縮資料將會引發 :exc:`EOFError`。任何在該 frame 結" +"束後找到的資料都會被忽略,並儲存在 :attr:`~.unused_data` 屬性中。" #: ../../library/compression.zstd.rst:350 msgid "``True`` if the end-of-stream marker has been reached." @@ -678,7 +680,7 @@ msgstr "" msgid "" "Parameters are optional; any omitted parameter will have its value selected " "automatically." -msgstr "" +msgstr "參數是可選的;任何省略的參數,其數值都會自動決定。" #: ../../library/compression.zstd.rst:505 msgid "" @@ -985,6 +987,8 @@ msgid "" "keys that can be used when decompressing data. Parameters are optional; any " "omitted parameter will have its value selected automatically." msgstr "" +"一個 :class:`~enum.IntEnum`,包含解壓縮資料時可以使用的進階解壓縮參數鍵。參數" +"是可選的;任何省略的參數,其數值都會自動決定。" #: ../../library/compression.zstd.rst:736 msgid "Example setting the :attr:`~.window_log_max` to the maximum size::" diff --git a/library/concurrent.futures.po b/library/concurrent.futures.po index 1badabc09f..0a1e171add 100644 --- a/library/concurrent.futures.po +++ b/library/concurrent.futures.po @@ -705,6 +705,8 @@ msgid "" "*max_workers* uses :func:`os.process_cpu_count` by default, instead of :func:" "`os.cpu_count`." msgstr "" +"*max_workers* 預設使用 :func:`os.process_cpu_count`,而非 :func:`os." +"cpu_count`。" #: ../../library/concurrent.futures.rst:418 msgid "" @@ -713,6 +715,9 @@ msgid "" "`ProcessPoolExecutor` you must explicitly pass ``mp_context=multiprocessing." "get_context(\"fork\")``." msgstr "" +"預設的行程啟動方法(參閱 :ref:`multiprocessing-start-methods`)已不再使用 " +"*fork*。如果你需要讓 :class:`ProcessPoolExecutor` 使用 *fork* 啟動方法,必須" +"明確傳入 ``mp_context=multiprocessing.get_context(\"fork\")``。" #: ../../library/concurrent.futures.rst:424 msgid "" @@ -720,6 +725,8 @@ msgid "" "process exited upon reaching its *max_tasks_per_child* limit while tasks " "remained queued." msgstr "" +"修正了一個死鎖問題 (:gh:`115634`):當工作行程因達到 *max_tasks_per_child* 上" +"限而結束、但仍有任務在佇列中等待時,executor 可能會卡住。" #: ../../library/concurrent.futures.rst:431 msgid "" diff --git a/library/concurrent.interpreters.po b/library/concurrent.interpreters.po index be6ff34b1d..46a9bd62df 100644 --- a/library/concurrent.interpreters.po +++ b/library/concurrent.interpreters.po @@ -47,6 +47,9 @@ msgid "" "is available separately through :mod:`threads ` -- see `below " "`_." msgstr "" +"就並行性而言,直譯器本身(以及此模組)所提供的,僅僅是隔離性,而這本身並沒有" +"多大用處。實際的並行性須另外透過\\ :mod:`執行緒 `\\ 取得,請參閱" +"\\ `下文 `_。" #: ../../library/concurrent.interpreters.rst:31 msgid ":class:`~concurrent.futures.InterpreterPoolExecutor`" @@ -309,7 +312,7 @@ msgstr "" msgid "" "There are a small number of Python types that actually share mutable data " "between interpreters:" -msgstr "" +msgstr "有少數幾種 Python 型別會實際在直譯器之間共享可變資料:" #: ../../library/concurrent.interpreters.rst:200 msgid ":class:`memoryview`" @@ -414,7 +417,7 @@ msgstr "" msgid "" "Return the result of running the given function in the interpreter (in the " "current thread)." -msgstr "" +msgstr "回傳在該直譯器(於目前執行緒中)執行給定函式的結果。" #: ../../library/concurrent.interpreters.rst:287 msgid "Run the given function in the interpreter (in a new thread)." diff --git a/library/contextlib.po b/library/contextlib.po index 3329471376..a32f3d6c36 100644 --- a/library/contextlib.po +++ b/library/contextlib.po @@ -140,6 +140,11 @@ msgid "" "that context managers support multiple invocations in order to be used as " "decorators)." msgstr "" +":deco:`contextmanager` 使用 :class:`ContextDecorator`,因此它所建立的情境管理" +"器除了可以在 :keyword:`with` 陳述式中使用外,也可以做為裝飾器使用。當作為裝飾" +"器使用時,每次函式呼叫都會隱式建立一個新的產生器實例(此舉讓原本「單次使" +"用」、由 :deco:`contextmanager` 建立的情境管理器,也能符合「情境管理器必須支" +"援多次呼叫才可用作裝飾器」的要求)。" #: ../../library/contextlib.rst:98 msgid "Use of :class:`ContextDecorator`." @@ -150,6 +155,8 @@ msgid "" "Similar to :deco:`~contextlib.contextmanager`, but creates an :ref:" "`asynchronous context manager `." msgstr "" +"與 :deco:`~contextlib.contextmanager` 類似,但建立的是\\ :ref:`非同步情境管理" +"器 `。" #: ../../library/contextlib.rst:107 msgid "" @@ -199,6 +206,8 @@ msgid "" "Context managers defined with :deco:`asynccontextmanager` can be used either " "as decorators or with :keyword:`async with` statements::" msgstr "" +"使用 :deco:`asynccontextmanager` 定義的情境管理器既可以做為裝飾器使用,也可以" +"搭配 :keyword:`async with` 陳述式使用: ::" #: ../../library/contextlib.rst:134 msgid "" @@ -225,12 +234,16 @@ msgid "" "created by :deco:`asynccontextmanager` to meet the requirement that context " "managers support multiple invocations in order to be used as decorators." msgstr "" +"當作為裝飾器使用時,每次函式呼叫都會隱式建立一個新的產生器實例。這讓原本「單" +"次使用」、由 :deco:`asynccontextmanager` 建立的情境管理器,也能符合「情境管理" +"器必須支援多次呼叫才可用作裝飾器」的要求。" #: ../../library/contextlib.rst:154 msgid "" "Async context managers created with :deco:`asynccontextmanager` can be used " "as decorators." msgstr "" +"使用 :deco:`asynccontextmanager` 建立的非同步情境管理器可以做為裝飾器使用。" #: ../../library/contextlib.rst:161 msgid "" @@ -603,6 +616,8 @@ msgid "" "``ContextDecorator`` is used by :deco:`contextmanager`, so you get this " "functionality automatically." msgstr "" +"``ContextDecorator`` 被 :deco:`contextmanager` 使用,因此你可以自動獲得這項功" +"能。" #: ../../library/contextlib.rst:406 msgid "Example of ``ContextDecorator``::" @@ -1015,9 +1030,8 @@ msgid "Similar to :meth:`ExitStack.close` but properly handles awaitables." msgstr "和 :meth:`ExitStack.close` 類似,但能夠正確處理可等待物件。" #: ../../library/contextlib.rst:657 -#, fuzzy msgid "Continuing the example for :deco:`asynccontextmanager`::" -msgstr "延續 :func:`asynccontextmanager` 的範例: ::" +msgstr "延續 :deco:`asynccontextmanager` 的範例: ::" #: ../../library/contextlib.rst:659 msgid "" @@ -1439,6 +1453,8 @@ msgid "" "context managers, and will complain about the underlying generator failing " "to yield if an attempt is made to use them a second time::" msgstr "" +"使用 :deco:`contextmanager` 建立的情境管理器同樣屬於單次使用的情境管理器,如" +"果嘗試第二次使用它們,將會因為底層產生器未能執行 yield 而回報錯誤: ::" #: ../../library/contextlib.rst:919 msgid "" diff --git a/library/csv.po b/library/csv.po index d2f2bf32bf..9861014e08 100644 --- a/library/csv.po +++ b/library/csv.po @@ -148,13 +148,15 @@ msgstr "" #: ../../library/csv.rst:86 msgid "where :file:`eggs.csv` contains:" -msgstr "" +msgstr "其中 :file:`eggs.csv` 包含:" #: ../../library/csv.rst:88 ../../library/csv.rst:124 msgid "" "Spam Spam Spam Spam Spam |Baked Beans|\n" "Spam |Lovely Spam| |Wonderful Spam|" msgstr "" +"Spam Spam Spam Spam Spam |Baked Beans|\n" +"Spam |Lovely Spam| |Wonderful Spam|" #: ../../library/csv.rst:96 msgid "" @@ -206,7 +208,7 @@ msgstr "" #: ../../library/csv.rst:122 msgid "which writes :file:`eggs.csv` containing:" -msgstr "" +msgstr "這會寫入 :file:`eggs.csv`,其內容為:" #: ../../library/csv.rst:132 msgid "" @@ -339,7 +341,7 @@ msgstr "" #: ../../library/csv.rst:210 msgid "where :file:`names.csv` contains:" -msgstr "" +msgstr "其中 :file:`names.csv` 包含:" #: ../../library/csv.rst:212 msgid "" @@ -347,6 +349,9 @@ msgid "" "Eric,Idle\n" "John,Cleese" msgstr "" +"first_name,last_name\n" +"Eric,Idle\n" +"John,Cleese" #: ../../library/csv.rst:222 msgid "" @@ -407,7 +412,7 @@ msgstr "" #: ../../library/csv.rst:255 msgid "which writes :file:`names.csv` containing:" -msgstr "" +msgstr "這會寫入 :file:`names.csv`,其內容為:" #: ../../library/csv.rst:257 msgid "" @@ -416,6 +421,10 @@ msgid "" "Lovely,Spam\n" "Wonderful,Spam" msgstr "" +"first_name,last_name\n" +"Baked,Beans\n" +"Lovely,Spam\n" +"Wonderful,Spam" #: ../../library/csv.rst:267 msgid "" @@ -504,6 +513,9 @@ msgid "" "in the :attr:`~Sniffer.preferred` attribute are preferred, in that order, no " "matter how many times each of them occurs." msgstr "" +"如果有多個分隔字元都同樣適合該樣本 -- 例如 ``','`` 和 ``';'`` 都能一致地分割" +"每一列 -- 則會依序偏好使用分隔字元 ``','``、``'\\t'``、``';'``、``' '`` 和 " +"``':'``,不論它們各自出現的次數為何。" #: ../../library/csv.rst:325 msgid "" @@ -544,9 +556,8 @@ msgstr "" "negatives)。" #: ../../library/csv.rst:342 -#, fuzzy msgid "The :class:`Sniffer` class has the following attribute:" -msgstr "類別 :class:`Sniffer` 提供了兩個 method:" +msgstr "類別 :class:`Sniffer` 具有以下屬性:" #: ../../library/csv.rst:346 msgid "" @@ -554,6 +565,8 @@ msgid "" "preference. It can be modified. Its initial value is ``[',', '\\t', ';', ' " "', ':']``." msgstr "" +"用於打破平局的偏好分隔字元清單,依偏好順序排列。此清單可以被修改,其初始值為 " +"``[',', '\\t', ';', ' ', ':']``。" #: ../../library/csv.rst:351 msgid "An example for :class:`Sniffer` use::" @@ -582,7 +595,6 @@ msgid "Instructs :class:`writer` objects to quote all fields." msgstr "引導 :class:`writer` 物件引用所有欄位。" #: ../../library/csv.rst:371 -#, fuzzy msgid "" "Instructs :class:`writer` objects to only quote those fields which contain " "special characters such as *delimiter*, *quotechar*, ``'\\r'``, ``'\\n'`` or " @@ -591,7 +603,9 @@ msgid "" "causing the field to be quoted." msgstr "" "引導 :class:`writer` 物件只引用包含特殊字元的欄位,例如:*delimiter*、" -"*quotechar*、``'\\r'``、``'\\n'`` 或是 *lineterminator* 的其他字元。" +"*quotechar*、``'\\r'``、``'\\n'`` 或是 *lineterminator* 中的其他字元。如果 " +"*doublequote* 為 :const:`False` 且已設定 *escapechar*,則會逸出 *quotechar*," +"而不是導致該欄位被引用。" #: ../../library/csv.rst:380 msgid "Instructs :class:`writer` objects to quote all non-numeric fields." @@ -757,7 +771,7 @@ msgstr "" #: ../../library/csv.rst:480 msgid "" "Previously the *escapechar* itself was not escaped, which lost it on reading." -msgstr "" +msgstr "先前 *escapechar* 本身並未被逸出,導致在讀取時遺失該字元。" #: ../../library/csv.rst:484 msgid "An empty *escapechar* is not allowed." diff --git a/library/ctypes.po b/library/ctypes.po index 261537ac4e..258538c8af 100644 --- a/library/ctypes.po +++ b/library/ctypes.po @@ -1153,6 +1153,8 @@ msgid "" "_as_parameter_` instance variable, you could define a :deco:`property` which " "makes the attribute available on request." msgstr "" +"如果你不想將實例的資料儲存在 :attr:`!_as_parameter_` 實例變數中,可以定義一" +"個 :deco:`property`,讓該屬性可依需求取得。" #: ../../library/ctypes.rst:559 msgid "Specifying the required argument types (function prototypes)" @@ -5107,7 +5109,7 @@ msgstr "" #: ../../library/ctypes.rst:3194 msgid "In favor of multiplication." -msgstr "" +msgstr "改用乘法運算。" #: ../../library/ctypes.rst:3200 msgid "Private, abstract base class for pointers." diff --git a/library/curses.ascii.po b/library/curses.ascii.po index 62a5aa98c9..a649987e78 100644 --- a/library/curses.ascii.po +++ b/library/curses.ascii.po @@ -211,7 +211,7 @@ msgstr "" #: ../../library/curses.ascii.rst:120 msgid "Checks for an ASCII blank character; space or horizontal tab." -msgstr "" +msgstr "檢查是否為 ASCII 空白字元;空格或水平定位字元。" #: ../../library/curses.ascii.rst:125 msgid "" @@ -226,7 +226,7 @@ msgstr "" #: ../../library/curses.ascii.rst:136 msgid "Checks for any ASCII printable character except space." -msgstr "" +msgstr "檢查是否為除了空格以外的任何 ASCII 可列印字元。" #: ../../library/curses.ascii.rst:141 msgid "Checks for an ASCII lower-case character." @@ -240,7 +240,7 @@ msgstr "" msgid "" "Checks for any ASCII printable character which is not a space or an " "alphanumeric character." -msgstr "" +msgstr "檢查是否為既非空格、也非字母數字字元的任何 ASCII 可列印字元。" #: ../../library/curses.ascii.rst:157 msgid "" @@ -263,6 +263,8 @@ msgid "" "Checks for an ASCII control character (ordinal values 0 to 31). Unlike :" "func:`iscntrl`, this does not include the delete character (0x7f)." msgstr "" +"檢查是否為 ASCII 控制字元(序數值 0 到 31)。與 :func:`iscntrl` 不同的是,這" +"不包括刪除字元(0x7f)。" #: ../../library/curses.ascii.rst:180 msgid "Checks for a non-ASCII character (ordinal values 0x80 and above)." diff --git a/library/curses.panel.po b/library/curses.panel.po index c53de41d0c..50345b7d1d 100644 --- a/library/curses.panel.po +++ b/library/curses.panel.po @@ -33,13 +33,12 @@ msgid "Functions" msgstr "函式" #: ../../library/curses.panel.rst:21 -#, fuzzy msgid "The module :mod:`!curses.panel` defines the following exception:" -msgstr ":mod:`!curses.panel` 模組定義了以下函式:" +msgstr ":mod:`!curses.panel` 模組定義了以下例外:" #: ../../library/curses.panel.rst:26 msgid "Exception raised when a curses panel library function returns an error." -msgstr "" +msgstr "當 curses panel 函式庫函式回傳錯誤時所引發的例外。" #: ../../library/curses.panel.rst:29 msgid "The module :mod:`!curses.panel` defines the following functions:" @@ -56,6 +55,9 @@ msgid "" "keep the returned panel object referenced explicitly. If you don't, the " "panel object is garbage collected and removed from the panel stack." msgstr "" +"回傳一個面板物件,將其與給定的視窗 *win* 建立關聯,並將新面板放置在面板堆疊的" +"最上層。請注意,你需要明確地保留對回傳面板物件的參照;如果不這樣做,該面板物" +"件將被垃圾回收並從面板堆疊中移除。" #: ../../library/curses.panel.rst:47 msgid "Returns the top panel in the panel stack." @@ -69,7 +71,7 @@ msgstr "" #: ../../library/curses.panel.rst:59 msgid "Panel objects" -msgstr "" +msgstr "面板物件" #: ../../library/curses.panel.rst:79 msgid "" @@ -78,6 +80,8 @@ msgid "" "determines the content, while the panel methods are responsible for the " "window's depth in the panel stack." msgstr "" +"如上述 :func:`new_panel` 所回傳的面板物件,是具有堆疊順序的視窗。面板總是會關" +"聯一個決定其內容的視窗,而面板方法則負責該視窗在面板堆疊中的深度。" #: ../../library/curses.panel.rst:84 msgid "Panel objects have the following methods:" @@ -124,7 +128,7 @@ msgstr "" msgid "" "Display the panel (which might have been hidden), placing it on top of the " "panel stack." -msgstr "" +msgstr "顯示該面板(可能已被隱藏),並將其放置在面板堆疊的最上層。" #: ../../library/curses.panel.rst:137 msgid "Push panel to the top of the stack." diff --git a/library/curses.po b/library/curses.po index 5261d86d70..5b559f77c1 100644 --- a/library/curses.po +++ b/library/curses.po @@ -66,6 +66,9 @@ msgid "" "integer is the code of a single encoded byte, optionally combined with " "attributes and a color pair, as returned by :meth:`window.inch`." msgstr "" +"當文件中提到\\ *字元*\\ 時,它可以被指定為一個整數、一個單一字元的 Unicode 字" +"串,或一個單位元組的 byte 字串。整數是單一已編碼位元組的代碼,並可選擇性地與" +"屬性和顏色對組合,如 :meth:`window.inch` 所回傳的值。" #: ../../library/curses.rst:36 msgid "" @@ -82,6 +85,11 @@ msgid "" "`~window.refresh`) release the :term:`GIL`, unsynchronized use from several " "threads can then crash the interpreter. Serialize the calls." msgstr "" +"curses 是否可從多個執行緒使用,取決於底層函式庫及其建置方式。在許多實作中(包" +"括 ncurses 的預設建置),螢幕狀態是共享的且非執行緒安全;由於封鎖和重新整理方" +"法(例如 :meth:`~window.getch` 和 :meth:`~window.refresh`)會釋放 :term:" +"`GIL`,因此從多個執行緒進行未同步的使用可能會導致直譯器崩潰。請將這些呼叫序列" +"化。" #: ../../library/curses.rst:53 msgid "Module :mod:`curses.ascii`" @@ -164,7 +172,7 @@ msgstr "" #: ../../library/curses.rst:100 msgid "This is an ncurses extension." -msgstr "" +msgstr "這是一個 ncurses 擴充功能。" #: ../../library/curses.rst:107 msgid "" @@ -202,6 +210,10 @@ msgid "" "will be between ``0`` (no component) and ``1000`` (maximum amount of " "component). Raise an exception if the color is not supported." msgstr "" +"回傳顏色 *color_number* 中紅色、綠色和藍色(RGB)分量的強度,其值必須介於 " +"``0`` 和 ``COLORS - 1`` 之間。回傳一個 3 元組,其中包含給定顏色的 R、G、B " +"值,數值介於 ``0``\\ (無此分量)和 ``1000``\\ (該分量的最大值)之間。如果不" +"支援該顏色,則引發例外。" #: ../../library/curses.rst:144 msgid "" @@ -248,6 +260,9 @@ msgid "" "representing the desired next state. The :func:`doupdate` function updates " "the physical screen to match the virtual screen." msgstr "" +"更新實體螢幕。curses 函式庫保留兩個資料結構,一個代表目前的實體螢幕內容,另一" +"個是代表所需下一個狀態的虛擬螢幕。:func:`doupdate` 函式會更新實體螢幕以符合虛" +"擬螢幕。" #: ../../library/curses.rst:188 msgid "" @@ -287,6 +302,11 @@ msgid "" "current line, and so are screen updates. This may be used for enabling " "character-at-a-time line editing without touching the rest of the screen." msgstr "" +":func:`.filter` 常式(如果使用)必須在呼叫 :func:`initscr` 之前呼叫。其效果" +"是,在初始化期間,:envvar:`LINES` 會被設為 ``1``;``clear``、``cup``、" +"``cud``、``cud1``、``cuu1``、``cuu``、``vpa`` 等功能會被停用;且 ``home`` 字" +"串會被設為 ``cr`` 的值。其效果是游標被限制在目前行內,螢幕更新也是如此。這可" +"用於在不影響螢幕其餘部分的情況下,啟用逐字元的行編輯功能。" #: ../../library/curses.rst:226 msgid "" @@ -336,6 +356,9 @@ msgid "" "that data, returning the new window object. The *file* argument must be a " "file object opened for reading in binary mode." msgstr "" +"讀取先前透過 :meth:`window.putwin` 呼叫儲存在檔案中的視窗相關資料。此常式接著" +"會使用該資料建立並初始化一個新視窗,並回傳新的視窗物件。*file* 引數必須是以二" +"進位模式開啟以供讀取的檔案物件。" #: ../../library/curses.rst:271 msgid "" @@ -349,6 +372,8 @@ msgid "" "``False``. Extended color support allows more than 256 color pairs for " "terminals that support more than 16 colors (for example, xterm-256color)." msgstr "" +"如果模組支援延伸色彩,則回傳 ``True``;否則回傳 ``False``。延伸色彩支援讓支援" +"超過 16 種顏色的終端機(例如 xterm-256color)能使用超過 256 組色彩對。" #: ../../library/curses.rst:279 msgid "Extended color support requires ncurses version 6.1 or later." @@ -419,7 +444,7 @@ msgstr "" #: ../../library/curses.rst:344 msgid "" "See :func:`setupterm` for a caveat about calling it before this function." -msgstr "" +msgstr "請參閱 :func:`setupterm`,以了解在呼叫此函式之前呼叫它的相關注意事項。" #: ../../library/curses.rst:348 msgid "" @@ -433,6 +458,8 @@ msgid "" "will flush all output in the terminal driver queue. If *flag* is ``False``, " "no flushing is done." msgstr "" +"如果 *flag* 為 ``True``,按下中斷鍵(interrupt、break 或 quit)將清空終端機驅" +"動程式佇列中的所有輸出。如果 *flag* 為 ``False``,則不會執行清空動作。" #: ../../library/curses.rst:361 msgid "" @@ -459,7 +486,7 @@ msgstr "" #: ../../library/curses.rst:380 msgid "Raise a :exc:`ValueError` if *k* is negative." -msgstr "" +msgstr "如果 *k* 為負數,則引發 :exc:`ValueError`。" #: ../../library/curses.rst:385 msgid "" @@ -489,6 +516,9 @@ msgid "" "sixth of a second. Use a negative *interval* to obtain the interval value " "without changing it." msgstr "" +"設定按下與放開事件之間可經過的最長時間(以毫秒為單位),以便將其識別為一次點" +"擊,並回傳先前的間隔值。預設值為 166 毫秒,即六分之一秒。使用負值的 " +"*interval* 可在不變更該值的情況下取得目前的間隔值。" #: ../../library/curses.rst:413 msgid "" @@ -498,6 +528,9 @@ msgid "" "previous value of the mouse event mask. If this function is never called, " "no mouse events are ever reported." msgstr "" +"設定要回報的滑鼠事件,並回傳一個元組 ``(availmask, oldmask)``。*availmask* 表" +"示指定的滑鼠事件中哪些可以被回報;若完全失敗則回傳 ``0``。*oldmask* 是先前的" +"滑鼠事件遮罩值。如果從未呼叫此函式,則永遠不會回報任何滑鼠事件。" #: ../../library/curses.rst:422 msgid "Sleep for *ms* milliseconds." @@ -524,6 +557,13 @@ msgid "" "arguments define a clipping box on the screen within which the pad region is " "to be displayed." msgstr "" +"pad 就像視窗一樣,只是它不受螢幕大小的限制,也不一定與螢幕的特定部分相關聯。" +"當需要一個大視窗,但同一時間只有其中一部分會顯示在螢幕上時,就可以使用 pad。" +"pad 不會自動重新整理(例如因捲動或輸入回顯而觸發)。pad 的 :meth:`~window." +"refresh` 和 :meth:`~window.noutrefresh` 方法需要 6 個引數,以指定要顯示的 " +"pad 部分,以及螢幕上用於顯示的位置。這些引數為 *pminrow*、*pmincol*、" +"*sminrow*、*smincol*、*smaxrow*、*smaxcol*;*p* 開頭的引數表示要顯示的 pad 區" +"域左上角座標,*s* 開頭的引數則定義螢幕上用來顯示該 pad 區域的裁切框。" #: ../../library/curses.rst:446 msgid "" @@ -546,7 +586,7 @@ msgstr "" #: ../../library/curses.rst:459 msgid "If *flag* is ``False``, the effect is the same as calling :func:`nonl`." -msgstr "" +msgstr "如果 *flag* 為 ``False``,其效果與呼叫 :func:`nonl` 相同。" #: ../../library/curses.rst:464 msgid "" @@ -599,12 +639,14 @@ msgid "" "terminfo capability, a bytes object, for the current terminal. Note that the " "output of :func:`putp` always goes to standard output." msgstr "" +"等同於 ``tputs(str, 1, putchar)``;為目前的終端機發出指定 terminfo 功能的值," +"該值為一個 bytes 物件。請注意,:func:`putp` 的輸出總是會被導向標準輸出。" #: ../../library/curses.rst:513 ../../library/curses.rst:656 #: ../../library/curses.rst:666 ../../library/curses.rst:676 #: ../../library/curses.rst:686 msgid ":func:`setupterm` (or :func:`initscr`) must be called first." -msgstr "" +msgstr "必須先呼叫 :func:`setupterm`\\ (或 :func:`initscr`)。" #: ../../library/curses.rst:518 msgid "" @@ -703,6 +745,8 @@ msgid "" "terminfo database entry could not be read. If the terminal has already been " "initialized, this function has no effect." msgstr "" +"如果找不到終端機,或無法讀取其 terminfo 資料庫項目,則引發 :exc:`curses." +"error`。如果終端機已經初始化,則此函式不會有任何作用。" #: ../../library/curses.rst:617 msgid "" @@ -710,6 +754,9 @@ msgid "" "func:`setupterm` allocated: the curses library keeps only a single current " "terminal and does not free the previously allocated one." msgstr "" +"在呼叫 :func:`setupterm` 之後呼叫 :func:`initscr` 會導致 :func:`setupterm` 配" +"置的終端機發生洩漏:curses 函式庫僅會保留單一個目前的終端機,並不會釋放先前配" +"置的那一個。" #: ../../library/curses.rst:625 msgid "" @@ -773,6 +820,9 @@ msgid "" "``b'\\033[6;4H'``, the exact result depending on terminal type. Up to nine " "integer parameters may be supplied." msgstr "" +"使用提供的參數實例化位元組物件 *str*,其中 *str* 應為從 terminfo 資料庫取得的" +"參數化字串。例如,``tparm(tigetstr(\"cup\"), 5, 3)`` 可能會得到 " +"``b'\\033[6;4H'``,實際結果取決於終端機類型。最多可提供九個整數參數。" #: ../../library/curses.rst:691 msgid "" @@ -797,6 +847,9 @@ msgid "" "represented as a caret followed by the character, for example as ``b'^C'``. " "Printing characters are left as they are." msgstr "" +"回傳一個 bytes 物件,其為字元 *ch* 的可列印表示形式;任何屬性和顏色對都會被忽" +"略。控制字元會以插入符號 (caret) 加上該字元來表示,例如 ``b'^C'``。可列印字元" +"則保持原樣。" #: ../../library/curses.rst:711 msgid "Push *ch* so the next :meth:`~window.getch` will return it." @@ -807,6 +860,8 @@ msgid "" "*ch* may be an integer (a key code or the code of an encoded byte), a byte, " "or a string of length 1 which encodes to a single byte." msgstr "" +"*ch* 可以是一個整數(按鍵代碼或已編碼位元組的代碼)、一個 byte,或一個長度為 " +"1 且會被編碼為單一位元組的字串。" #: ../../library/curses.rst:718 msgid "Only one *ch* can be pushed before :meth:`!getch` is called." @@ -826,7 +881,7 @@ msgstr "" msgid "" "*ch* may be an integer (a character code, not a key code) or a string of " "length 1." -msgstr "" +msgstr "*ch* 可以是一個整數(字元代碼,而非按鍵代碼)或一個長度為 1 的字串。" #: ../../library/curses.rst:738 msgid "Only one *ch* can be pushed before :meth:`!get_wch` is called." @@ -868,7 +923,7 @@ msgstr "" #: ../../library/curses.rst:780 msgid "Window objects" -msgstr "" +msgstr "視窗物件" #: ../../library/curses.rst:784 msgid "" @@ -889,6 +944,8 @@ msgid "" "Attempting to write to the lower-right corner of a window, subwindow, or pad " "will cause an exception to be raised after the character is printed." msgstr "" +"在視窗、子視窗或 pad 之外寫入會引發 :exc:`curses.error`。嘗試寫入視窗、子視窗" +"或 pad 的右下角時,會在該字元印出後引發例外。" #: ../../library/curses.rst:805 msgid "" @@ -908,6 +965,8 @@ msgid "" "Attempting to write to the lower-right corner of a window, subwindow, or pad " "will cause an exception to be raised after the string is printed." msgstr "" +"在視窗、子視窗或 pad 之外寫入會引發 :exc:`curses.error`。嘗試寫入視窗、子視窗" +"或 pad 的右下角時,會在該字串印出後引發例外。" #: ../../library/curses.rst:822 msgid "" @@ -917,6 +976,10 @@ msgid "" "meth:`!addstr` with a *str* that has embedded newlines; instead, call :meth:" "`!addstr` separately for each line." msgstr "" +"此 Python 模組後端 ncurses 中的一個錯誤,可能會在調整視窗大小時導致 " +"segfault。此問題已在 ncurses-6.1-20190511 中修正。如果你仍在使用較舊版本的 " +"ncurses,可以透過不對含有內嵌換行字元的 *str* 呼叫 :meth:`!addstr` 來避免觸發" +"此問題;改為針對每一行分別呼叫 :meth:`!addstr`。" #: ../../library/curses.rst:831 msgid "" @@ -1130,6 +1193,8 @@ msgid "" "Delete the character under the cursor, or at ``(y, x)`` if specified. All " "characters to the right on the same line are shifted one position left." msgstr "" +"刪除游標所在位置的字元,若有指定則刪除 ``(y, x)`` 位置的字元。同一行中右側的" +"所有字元都會向左移動一個位置。" #: ../../library/curses.rst:959 msgid "" @@ -1171,6 +1236,9 @@ msgid "" "for example with :meth:`window.subwin`. By default, current locale encoding " "is used (see :func:`locale.getencoding`)." msgstr "" +"在未支援寬字元的建置版本中,用來編碼方法的字串引數以及解碼其回傳結果的編碼。" +"當建立子視窗時(例如透過 :meth:`window.subwin`),編碼屬性會繼承自父視窗。預" +"設情況下會使用目前的區域編碼(請參閱 :func:`locale.getencoding`)。" #: ../../library/curses.rst:1001 msgid "Clear the window." @@ -1181,11 +1249,12 @@ msgid "Return a tuple ``(y, x)`` of coordinates of upper-left corner." msgstr "回傳左上角的座標 ``(y, x)``。" #: ../../library/curses.rst:1011 -#, fuzzy msgid "" "Return the given window's current background character/attribute pair. Its " "components can be extracted like those of :meth:`inch`." -msgstr "回傳給定視窗目前的背景字元/屬性對。" +msgstr "" +"回傳給定視窗目前的背景字元/屬性對。其組成部分可以像 :meth:`inch` 的結果一樣被" +"提取出來。" #: ../../library/curses.rst:1017 msgid "" @@ -1195,6 +1264,10 @@ msgid "" "return ``-1`` if the read is non-blocking or times out (see :meth:`nodelay` " "and :meth:`timeout`)." msgstr "" +"讀取一次按鍵,若有指定 *y*、*x* 則先將游標移動到該處,並以整數形式回傳。如果" +"該視窗不是 pad 且自上次重新整理後已被修改,則會先重新整理它。等待直到有按鍵被" +"按下,或者在讀取為非阻塞或逾時的情況下回傳 ``-1``\\ (請參閱 :meth:`nodelay` " +"和 :meth:`timeout`)。" #: ../../library/curses.rst:1024 msgid "" @@ -1203,6 +1276,10 @@ msgid "" "calls. For example, in a UTF-8 locale ``'é'`` is read as ``195``, then " "``169``. Use :meth:`get_wch` to read it as a single character." msgstr "" +"一般按鍵會以其在目前語言環境 (locale) 中編碼的單一位元組代碼回傳,因此一個以" +"多個位元組編碼的字元需要多次呼叫才能讀取完畢。舉例來說,在 UTF-8 語言環境下," +"``'é'`` 會先讀到 ``195``,接著讀到 ``169``。若要將其讀取為單一字元,請使用 :" +"meth:`get_wch`。" #: ../../library/curses.rst:1030 msgid "" @@ -1212,12 +1289,18 @@ msgid "" "sequence does not arrive in time (see :meth:`notimeout` and :func:" "`set_escdelay`), their bytes are returned one at a time." msgstr "" +"在鍵盤模式 (keypad mode,請參閱 :meth:`keypad`) 下,功能鍵和其他特殊按鍵會" +"以 :ref:`KEY_* 常數之一 ` 的形式回傳,因此不會與一般按" +"鍵混淆。否則,或者如果它們的跳脫序列 (escape sequence) 未能及時送達(請參閱 :" +"meth:`notimeout` 和 :func:`set_escdelay`),則會逐一位元組回傳。" #: ../../library/curses.rst:1037 ../../library/curses.rst:1057 msgid "" "In echo mode (see :func:`echo`) the key is added to the window as by :meth:" "`addch`; special keys are not echoed." msgstr "" +"在回顯模式 (echo mode,請參閱 :func:`echo`) 下,該按鍵會以 :meth:`addch` 的方" +"式被加入到視窗中;特殊按鍵則不會被回顯。" #: ../../library/curses.rst:1043 msgid "" @@ -1227,6 +1310,10 @@ msgid "" "pressed, or raise :exc:`error` if the read is non-blocking or times out " "(see :meth:`nodelay` and :meth:`timeout`)." msgstr "" +"讀取一次按鍵,若有指定 *y*、*x* 則先將游標移動到該處,並以單一字元的 :class:" +"`str` 形式回傳。如果該視窗不是 pad 且自上次重新整理後已被修改,則會先重新整理" +"它。等待直到有按鍵被按下,或者在讀取為非阻塞或逾時的情況下引發 :exc:" +"`error`\\ (請參閱 :meth:`nodelay` 和 :meth:`timeout`)。" #: ../../library/curses.rst:1050 msgid "" @@ -1236,6 +1323,10 @@ msgid "" "(see :meth:`notimeout` and :func:`set_escdelay`), their characters are " "returned one at a time." msgstr "" +"在鍵盤模式 (keypad mode,請參閱 :meth:`keypad`) 下,功能鍵和其他特殊按鍵會" +"以 :ref:`KEY_* 常數之一 `\\ (一個整數)的形式回傳。否" +"則,或者如果它們的跳脫序列 (escape sequence) 未能及時送達(請參閱 :meth:" +"`notimeout` 和 :func:`set_escdelay`),則會逐一字元回傳。" #: ../../library/curses.rst:1065 msgid "" @@ -1244,6 +1335,10 @@ msgid "" "special key as its name, such as ``'KEY_UP'`` (see :func:`keyname`). Raise :" "exc:`error` instead of returning ``-1`` if there is no input." msgstr "" +"以與 :meth:`getch` 相同的方式讀取一次按鍵,但以 :class:`str` 形式回傳:一般按" +"鍵會是單一字元的字串(該位元組以 Latin-1 解碼),特殊按鍵則會是其名稱,例如 " +"``'KEY_UP'``\\ (請參閱 :func:`keyname`)。若沒有輸入,則引發 :exc:`error` 而" +"非回傳 ``-1``。" #: ../../library/curses.rst:1073 msgid "Return a tuple ``(y, x)`` of the height and width of the window." @@ -1263,6 +1358,8 @@ msgid "" "object, in the encoding of the current locale and without the terminating " "newline. At most *n* bytes are read; *n* defaults to and cannot exceed 2047." msgstr "" +"從使用者處讀取一個位元組物件,具備基本的行編輯功能。最多讀取 *n* 個字元;*n* " +"預設且不能超過 2047。" #: ../../library/curses.rst:1095 ../../library/curses.rst:1200 msgid "The maximum value for *n* was increased from 1023 to 2047." @@ -1280,6 +1377,8 @@ msgid "" "of the character *ch* with attributes *attr*. The line stops at the right " "edge of the window if fewer than *n* cells are available." msgstr "" +"從 ``(y, x)`` 開始顯示一條長度為 *n* 的水平線,由具有屬性 *attr* 的字元 *ch* " +"組成。如果可用的儲存格數少於 *n* 個,該線會在視窗右緣停止。" #: ../../library/curses.rst:1115 msgid "" @@ -1294,6 +1393,8 @@ msgid "" "If *flag* is ``True``, :mod:`!curses` will try to use hardware line editing " "facilities. Otherwise, curses will not use them." msgstr "" +"如果 *flag* 為 ``True``,:mod:`!curses` 將嘗試使用硬體行編輯功能。否則," +"curses 將不會使用這些功能。" #: ../../library/curses.rst:1129 msgid "" @@ -1314,6 +1415,9 @@ msgid "" "current locale has a character byte of ``0``; use :meth:`instr` to read such " "characters." msgstr "" +"回傳視窗中給定位置的字元。最低的 8 位元是字元本身,較高位元則是屬性;可分別使" +"用 :data:`A_CHARTEXT` 和 :data:`A_ATTRIBUTES` 位元遮罩取出,並使用 :func:" +"`pair_number` 取出色彩對。" #: ../../library/curses.rst:1151 msgid "" @@ -1322,6 +1426,9 @@ msgid "" "cursor are shifted one position right, with the rightmost character on the " "line being lost. The cursor position does not change." msgstr "" +"在游標所在位置的字元之前插入具有屬性 *attr* 的字元 *ch*,若有指定則插入到 " +"``(y, x)`` 位置。游標右側的所有字元都會向右移動一個位置,該行最右側的字元將會" +"遺失。游標位置不會改變。" #: ../../library/curses.rst:1159 msgid "" @@ -1364,6 +1471,10 @@ msgid "" "in the encoding of the current locale. Attributes and color pairs are " "stripped. At most *n* bytes are read; *n* defaults to and cannot exceed 2047." msgstr "" +"回傳一個位元組物件,內容為從目前游標位置(若有指定則為 *y*、*x* 位置)開始擷" +"取的字元,直到該行結尾為止。字元的屬性和色彩資訊會被移除。如果有指定 *n*,:" +"meth:`instr` 會回傳最多 *n* 個字元長的字串(不含結尾的 NUL)。*n* 的最大值為 " +"2047。" #: ../../library/curses.rst:1206 msgid "" @@ -1386,12 +1497,17 @@ msgid "" "mode is disabled by default, but :func:`wrapper` enables it for the main " "window." msgstr "" +"如果 *flag* 為 ``True``,某些按鍵(keypad、功能鍵)產生的跳脫序列將由 :mod:`!" +"curses` 解讀。如果 *flag* 為 ``False``,跳脫序列會原樣保留在輸入串流中。鍵盤" +"模式預設為停用,但 :func:`wrapper` 會為主視窗啟用它。" #: ../../library/curses.rst:1228 msgid "" "If *flag* is ``True``, cursor is left where it is on update, instead of " "being at \"cursor position.\" This reduces cursor movement where possible." msgstr "" +"如果 *flag* 為 ``True``,更新時游標會保留在原處,而不是移到「游標位置」。這樣" +"可以盡可能減少游標的移動。" #: ../../library/curses.rst:1231 msgid "" @@ -1419,6 +1535,8 @@ msgid "" "Moving the window so that any part of it would be off the screen is an " "error: the window is not moved and :exc:`curses.error` is raised." msgstr "" +"若移動視窗會使其任何部分超出螢幕範圍,則視為錯誤:視窗將不會被移動,並會引" +"發 :exc:`curses.error`。" #: ../../library/curses.rst:1256 msgid "If *flag* is ``True``, :meth:`getch` will be non-blocking." @@ -1447,6 +1565,8 @@ msgid "" "window is a pad created with :func:`newpad`; they have the same meaning as " "for :meth:`refresh`." msgstr "" +"這 6 個引數只有在視窗是使用 :func:`newpad` 建立的 pad 時才能指定,且此時為必" +"要引數;它們的意義與 :meth:`refresh` 中的相同。" #: ../../library/curses.rst:1281 msgid "" @@ -1518,6 +1638,12 @@ msgid "" "Negative values of *pminrow*, *pmincol*, *sminrow*, or *smincol* are treated " "as if they were zero." msgstr "" +"這 6 個引數只有在視窗是使用 :func:`newpad` 建立的 pad 時才能指定,且此時為必" +"要引數。這些額外的參數用於指出涉及 pad 和螢幕的哪個部分。*pminrow* 和 " +"*pmincol* 指定要在 pad 中顯示的矩形左上角。*sminrow*、*smincol*、*smaxrow* " +"和 *smaxcol* 指定要在螢幕上顯示的矩形邊界。由於兩個矩形的大小必須相同,pad 中" +"要顯示的矩形右下角會由螢幕座標計算得出。兩個矩形都必須完全包含在各自的結構" +"內。*pminrow*、*pmincol*、*sminrow* 或 *smincol* 的負值會被視為零。" #: ../../library/curses.rst:1342 msgid "" @@ -1533,6 +1659,9 @@ msgid "" "*lines* is positive, or downward if it is negative. Scrolling has no effect " "unless it has been enabled for the window with :meth:`scrollok`." msgstr "" +"捲動螢幕或捲動區域。如果 *lines* 為正值,則向上捲動 *lines* 行;如果為負值," +"則向下捲動。除非已使用 :meth:`scrollok` 為該視窗啟用捲動功能,否則捲動不會產" +"生任何效果。" #: ../../library/curses.rst:1357 msgid "" @@ -1567,6 +1696,9 @@ msgid "" "parent pad (unlike :meth:`subwin`, which uses screen coordinates). This " "method is only available for pads created with :func:`newpad`." msgstr "" +"回傳一個子 pad,其左上角位於 ``(begin_y, begin_x)``,寬度/高度為 *ncols*/" +"*nlines*。座標是相對於父 pad 而言(不同於 :meth:`subwin`,後者使用的是螢幕座" +"標)。此方法僅適用於以 :func:`newpad` 建立的 pad。" #: ../../library/curses.rst:1394 msgid "" @@ -1574,6 +1706,8 @@ msgid "" "coordinates ``(begin_y, begin_x)``, and whose width/height is *ncols*/" "*nlines*." msgstr "" +"回傳一個子視窗,其左上角位於螢幕相對座標 ``(begin_y, begin_x)``,寬度/高度為 " +"*ncols*/*nlines*。" #: ../../library/curses.rst:1397 msgid "" @@ -1690,6 +1824,8 @@ msgid "" "after the call to :func:`initscr`. Updated by :func:`update_lines_cols`, :" "func:`resizeterm` and :func:`resize_term`." msgstr "" +"螢幕的寬度,也就是欄數。僅在呼叫 :func:`initscr` 之後才會被定義。會由 :func:" +"`update_lines_cols`、:func:`resizeterm` 和 :func:`resize_term` 更新。" #: ../../library/curses.rst:1509 msgid "" @@ -1697,6 +1833,8 @@ msgid "" "after the call to :func:`initscr`. Updated by :func:`update_lines_cols`, :" "func:`resizeterm` and :func:`resize_term`." msgstr "" +"螢幕的高度,也就是行數。僅在呼叫 :func:`initscr` 之後才會被定義。會由 :func:" +"`update_lines_cols`、:func:`resizeterm` 和 :func:`resize_term` 更新。" #: ../../library/curses.rst:1515 msgid "" @@ -2284,7 +2422,7 @@ msgstr "" #: ../../library/curses.rst:1814 msgid "alternate name for upper-right corner" -msgstr "" +msgstr "右上角的替代名稱" #: ../../library/curses.rst:1816 msgid "solid square block" @@ -2352,11 +2490,11 @@ msgstr "" #: ../../library/curses.rst:1848 msgid "lower-left corner" -msgstr "" +msgstr "左下角" #: ../../library/curses.rst:1850 msgid "lower-right corner" -msgstr "" +msgstr "右下角" #: ../../library/curses.rst:1852 msgid "left tee" @@ -2404,7 +2542,7 @@ msgstr "" #: ../../library/curses.rst:1874 msgid "alternate name for lower-right corner" -msgstr "" +msgstr "右下角的替代名稱" #: ../../library/curses.rst:1876 msgid "alternate name for vertical line" @@ -2416,7 +2554,7 @@ msgstr "" #: ../../library/curses.rst:1880 msgid "alternate name for lower-left corner" -msgstr "" +msgstr "左下角的替代名稱" #: ../../library/curses.rst:1882 msgid "alternate name for bottom tee" @@ -2444,11 +2582,11 @@ msgstr "" #: ../../library/curses.rst:1894 msgid "upper-left corner" -msgstr "" +msgstr "左上角" #: ../../library/curses.rst:1896 msgid "upper-right corner" -msgstr "" +msgstr "右上角" #: ../../library/curses.rst:1898 msgid "vertical line" @@ -2493,7 +2631,7 @@ msgstr "" #: ../../library/curses.rst:1920 msgid "Alt was down during button state change" -msgstr "" +msgstr "按鈕狀態變更時 Alt 鍵處於按下狀態" #: ../../library/curses.rst:1927 msgid "The following table lists the predefined colors:" @@ -2564,6 +2702,10 @@ msgid "" "(including xterm and most other software terminal emulators). Otherwise it " "will be drawn with ASCII dashes, vertical bars, and plus signs." msgstr "" +"繪製一個矩形。第一個引數必須是視窗物件;其餘引數是相對於該視窗的座標。第二個" +"和第三個引數是要繪製矩形左上角的 y 和 x 座標;第四個和第五個引數是右下角的 y " +"和 x 座標。在支援的終端機(包括 xterm 和大多數其他軟體終端機模擬器)上,矩形" +"會使用 VT100/IBM PC 表單字元繪製。否則會使用 ASCII 破折號、直線和加號繪製。" #: ../../library/curses.rst:1983 msgid "Textbox objects" @@ -2583,6 +2725,10 @@ msgid "" "containing window, with coordinates ``(0, 0)``. The instance's :attr:" "`stripspaces` flag is initially on." msgstr "" +"回傳一個文字框元件物件。*win* 引數應為容納此文字框的 curses :ref:`視窗 " +"` 物件。如果 *insert_mode* 為 true,文字框會插入輸入的" +"字元,將現有文字向右移動,而不是覆蓋它。文字框的編輯游標初始位置在容納視窗的" +"左上角,座標為 ``(0, 0)``。該實例的 :attr:`stripspaces` 旗標初始為開啟狀態。" #: ../../library/curses.rst:1998 msgid ":class:`Textbox` objects have the following methods:" @@ -2598,6 +2744,11 @@ msgid "" "This method returns the window contents as a string; whether blanks in the " "window are included is affected by the :attr:`stripspaces` attribute." msgstr "" +"這是你通常會使用的進入點。它會接受編輯按鍵,直到輸入其中一個終止按鍵為止。如" +"果有提供 *validate*,它必須是一個函式。每輸入一個按鍵,就會以該按鍵作為參數呼" +"叫它一次;命令的分派是根據其回傳結果進行的。如果它回傳假值,該按鍵將被忽略。" +"此方法會以字串形式回傳視窗內容;視窗中的空白是否會被包含在內,則受 :attr:" +"`stripspaces` 屬性影響。" #: ../../library/curses.rst:2015 msgid "" @@ -2605,6 +2756,8 @@ msgid "" "``0`` if a termination keystroke was processed. Here are the supported " "special keystrokes:" msgstr "" +"處理單一個命令按鍵。若要繼續編輯則回傳 ``1``,若已處理終止按鍵則回傳 ``0``。" +"以下是支援的特殊按鍵:" #: ../../library/curses.rst:2020 ../../library/curses.rst:2059 msgid "Keystroke" @@ -2678,7 +2831,7 @@ msgstr ":kbd:`Control-J`" msgid "" "Terminate if the window is 1 line, otherwise move to the start of the next " "line." -msgstr "" +msgstr "如果視窗只有 1 行則終止,否則移動到下一行的開頭。" #: ../../library/curses.rst:2043 msgid ":kbd:`Control-K`" diff --git a/library/dataclasses.po b/library/dataclasses.po index dcfc903aa6..14122c04fe 100644 --- a/library/dataclasses.po +++ b/library/dataclasses.po @@ -24,7 +24,6 @@ msgid "**Source code:** :source:`Lib/dataclasses.py`" msgstr "**原始碼:**\\ :source:`Lib/dataclasses.py`" #: ../../library/dataclasses.rst:14 -#, fuzzy msgid "" "This module provides a decorator and functions for automatically adding " "generated :term:`special methods ` such as :meth:`~object." @@ -36,7 +35,6 @@ msgstr "" "定義的類別。它最初在 :pep:`557` 中描述。" #: ../../library/dataclasses.rst:19 -#, fuzzy msgid "" "The member variables to use in these generated methods are defined using :" "pep:`526` type annotations. For example, this code::" @@ -60,7 +58,6 @@ msgid "" msgstr "" #: ../../library/dataclasses.rst:34 -#, fuzzy msgid "will add, among other things, a :meth:`!__init__` that looks like::" msgstr "將新增,除其他事項外,一個 :meth:`!__init__` 看起來像: ::" @@ -79,7 +76,6 @@ msgstr "" " self.quantity_on_hand = quantity_on_hand" #: ../../library/dataclasses.rst:41 -#, fuzzy msgid "" "Note that this method is automatically added to the class: it is not " "directly specified in the :class:`!InventoryItem` definition shown above." @@ -92,7 +88,6 @@ msgid "Module contents" msgstr "模組內容" #: ../../library/dataclasses.rst:51 -#, fuzzy msgid "" "This function is a :term:`decorator` that is used to add generated :term:" "`special methods ` to classes, as described below." @@ -101,7 +96,6 @@ msgstr "" "method>`\\新增到類別中,如下所述。" #: ../../library/dataclasses.rst:54 -#, fuzzy msgid "" "The ``@dataclass`` decorator examines the class to find ``field``\\s. A " "``field`` is defined as a class variable that has a :term:`type annotation " @@ -113,7 +107,6 @@ msgstr "" "外,``@dataclass`` 中沒有任何內容檢查變數註釋中指定的型別。" #: ../../library/dataclasses.rst:60 -#, fuzzy msgid "" "The order of the fields in all of the generated methods is the order in " "which they appear in the class definition." @@ -132,7 +125,6 @@ msgstr "" "同一個類別;不會建立新類別。" #: ../../library/dataclasses.rst:69 -#, fuzzy msgid "" "If ``@dataclass`` is used just as a simple decorator with no parameters, it " "acts as if it has the default values documented in this signature. That is, " @@ -187,7 +179,6 @@ msgid "" msgstr "如果該類別已經定義了 :meth:`!__init__`,則此參數會被忽略。" #: ../../library/dataclasses.rst:95 -#, fuzzy msgid "" "*repr*: If true (the default), a :meth:`~object.__repr__` method will be " "generated. The generated repr string will have the class name and the name " @@ -196,10 +187,10 @@ msgid "" "example: ``InventoryItem(name='widget', unit_price=3.0, " "quantity_on_hand=10)``." msgstr "" -"*repr*:如果為真(預設值),將生成一個 :meth:`__repr__` 方法。生成的 repr 字" -"串將包含類別名稱以及每個欄位的名稱和 repr,按照它們在類別中定義的順序排列。不" -"包括標記為從 repr 中排除的欄位。例如:``InventoryItem(name='widget', " -"unit_price=3.0, quantity_on_hand=10)``。" +"*repr*:如果為真(預設值),將生成一個 :meth:`~object.__repr__` 方法。生成的 " +"repr 字串將依欄位在類別中定義的順序,包含類別名稱以及每個欄位的名稱和 repr。" +"標記為從 repr 中排除的欄位則不會被包括在內。例如:" +"``InventoryItem(name='widget', unit_price=3.0, quantity_on_hand=10)``。" #: ../../library/dataclasses.rst:102 msgid "" @@ -229,6 +220,8 @@ msgid "" "example, ``self.a == other.a and self.b == other.b``), rather than comparing " "tuples of fields as in previous versions." msgstr "" +"生成的 ``__eq__`` 方法現在會逐一比較每個欄位(例如 ``self.a == other.a and " +"self.b == other.b``),而不是像先前版本那樣比較欄位的 tuple。" #: ../../library/dataclasses.rst:118 msgid "" @@ -236,6 +229,8 @@ msgid "" "where attributes compare equal by identity but not by value (such as " "``float('nan')``)." msgstr "" +"此變更使比較速度更快,但在屬性依識別性相等、卻依數值不相等的情況下(例如 " +"``float('nan')``),可能會改變比較結果。" #: ../../library/dataclasses.rst:122 msgid "" @@ -243,9 +238,10 @@ msgid "" "of the fields and comparing them (for example, ``(self.a, self.b) == (other." "a, other.b)``)." msgstr "" +"在 Python 3.12 及更早版本中,比較是透過建立欄位的 tuple 並進行比較來執行的" +"(例如 ``(self.a, self.b) == (other.a, other.b)``)。" #: ../../library/dataclasses.rst:126 -#, fuzzy msgid "" "*order*: If true (the default is ``False``), :meth:`~object.__lt__`, :meth:" "`~object.__le__`, :meth:`~object.__gt__`, and :meth:`~object.__ge__` methods " @@ -253,10 +249,10 @@ msgid "" "fields, in order. Both instances in the comparison must be of the identical " "type. If *order* is true and *eq* is false, a :exc:`ValueError` is raised." msgstr "" -"*order*:如果為真(預設為 ``False``),:meth:`~object.__lt__`、:meth:" -"`~object.__le__`、:meth:`~object.__gt__` 和 :meth:`~object.__ge__` 方法將是產" -"生。它們按順序比較類別,就好像它是其欄位的元組一樣。比較中的兩個實例必須屬於" -"同一型別。如果 *order* 為真且 *eq* 為假,則會引發 :exc:`ValueError`。" +"*order*:如果為真(預設為 ``False``),將會生成 :meth:`~object.__lt__`、:" +"meth:`~object.__le__`、:meth:`~object.__gt__` 和 :meth:`~object.__ge__` 方" +"法。這些方法會依序將類別比較為其欄位的 tuple。比較中的兩個實例必須屬於同一型" +"別。如果 *order* 為真而 *eq* 為假,則會引發 :exc:`ValueError`。" #: ../../library/dataclasses.rst:133 msgid "" @@ -267,18 +263,17 @@ msgstr "" "meth:`!__ge__` 中的任何一個,則引發 :exc:`TypeError`。" #: ../../library/dataclasses.rst:137 -#, fuzzy msgid "" "*unsafe_hash*: If true, force ``dataclasses`` to create a :meth:`~object." "__hash__` method, even though it may not be safe to do so. Otherwise, " "generate a :meth:`~object.__hash__` method according to how *eq* and " "*frozen* are set. The default value is ``False``." msgstr "" -"*unsafe_hash*:如果 ``False``\\ (預設值),將根據 *eq* 和 *frozen* 的設定生" -"成一個 :meth:`~object.__hash__` 方法。" +"*unsafe_hash*:如果為真,將強制 ``dataclasses`` 建立一個 :meth:`~object." +"__hash__` 方法,即使這樣做可能並不安全。否則,會根據 *eq* 和 *frozen* 的設定" +"方式來生成 :meth:`~object.__hash__` 方法。預設值為 ``False``。" #: ../../library/dataclasses.rst:143 -#, fuzzy msgid "" ":meth:`!__hash__` is used by built-in :meth:`hash`, and when objects are " "added to hashed collections such as dictionaries and sets. Having a :meth:`!" @@ -287,13 +282,12 @@ msgid "" "and behavior of :meth:`!__eq__`, and the values of the *eq* and *frozen* " "flags in the ``@dataclass`` decorator." msgstr "" -":meth:`!__hash__` 由內建的 :meth:`hash` 使用,當物件被新增到雜湊集合(如字典" -"和集合)時。擁有 :meth:`!__hash__` 意味著該類別的實例是不可變的。可變性是一個" -"複雜的屬性,它取決於程序設計師的意圖 :meth:`!__eq__` 的存在和行為,以及 " -"dataclass 裝飾器中的 *eq* 和 *frozen* 旗標的值." +":meth:`!__hash__` 由內建的 :meth:`hash` 使用,也會在物件被新增到如字典和集合" +"等雜湊集合時使用。擁有 :meth:`!__hash__` 意味著該類別的實例是不可變的。可變性" +"是一個複雜的屬性,取決於程式設計師的意圖、:meth:`!__eq__` 的存在與行為,以及 " +"``@dataclass`` 裝飾器中 *eq* 和 *frozen* 旗標的值。" #: ../../library/dataclasses.rst:150 -#, fuzzy msgid "" "By default, ``@dataclass`` will not implicitly add a :meth:`~object." "__hash__` method unless it is safe to do so. Neither will it add or change " @@ -307,7 +301,6 @@ msgstr "" "件中所述。" #: ../../library/dataclasses.rst:156 -#, fuzzy msgid "" "If :meth:`!__hash__` is not explicitly defined, or if it is set to ``None``, " "then ``@dataclass`` *may* add an implicit :meth:`!__hash__` method. Although " @@ -323,7 +316,6 @@ msgstr "" "個特殊的用例,應該仔細考慮。" #: ../../library/dataclasses.rst:163 -#, fuzzy msgid "" "Here are the rules governing implicit creation of a :meth:`!__hash__` " "method. Note that you cannot both have an explicit :meth:`!__hash__` method " @@ -351,15 +343,13 @@ msgstr "" "別是 :class:`object`,這意味著它將回退到基於 id 的雜湊)。" #: ../../library/dataclasses.rst:176 -#, fuzzy msgid "" "*frozen*: If true (the default is ``False``), assigning to fields will " "generate an exception. This emulates read-only frozen instances. See the :" "ref:`discussion ` below." msgstr "" -"*frozen*:如果為真(預設為 ``False``),分配給欄位將產生例外。這模擬了只讀的" -"凍結實例。如果 :meth:`~object.__setattr__` 或 :meth:`~object.__delattr__` 在" -"類別中定義,則 :exc:`TypeError` 被引發。請參閱下面的討論。" +"*frozen*:如果為真(預設為 ``False``),對欄位賦值將會產生例外。這模擬了唯讀" +"的凍結實例。請參閱下面的\\ :ref:`討論 `。" #: ../../library/dataclasses.rst:180 msgid "" @@ -370,7 +360,6 @@ msgstr "" "且 *frozen* 為真,則會引發 :exc:`TypeError`。" #: ../../library/dataclasses.rst:183 -#, fuzzy msgid "" "*match_args*: If true (the default is ``True``), the :attr:`~object." "__match_args__` tuple will be created from the list of non keyword-only " @@ -379,13 +368,12 @@ msgid "" "__match_args__` is already defined in the class, then :attr:`!" "__match_args__` will not be generated." msgstr "" -"*match_args*:如果為真(預設為 ``True``),``__match_args__`` 元組將從參數列" -"表建立到生成的 :meth:`~object.__init__` 方法(即使 :meth: `!__init__` 未生" -"成,見上文)。如果為 false,或者類別中已經定義了 :attr:`!__match_args__`,則" -"不會生成 :attr:`!__match_args__`。" +"*match_args*:如果為真(預設為 ``True``),:attr:`~object.__match_args__` " +"tuple 將依據傳給生成的 :meth:`~object.__init__` 方法的非僅限關鍵字參數列表建" +"立(即使未生成 :meth:`!__init__` 方法也一樣,見上文)。如果為假,或類別中已經" +"定義了 :attr:`!__match_args__`,則不會生成 :attr:`!__match_args__`。" #: ../../library/dataclasses.rst:192 -#, fuzzy msgid "" "*kw_only*: If true (the default value is ``False``), then all fields will be " "marked as keyword-only. If a field is marked as keyword-only, then the only " @@ -394,27 +382,25 @@ msgid "" "is called. See the :term:`parameter` glossary entry for details. Also see " "the :const:`KW_ONLY` section." msgstr "" -"``kw_only``:如果為 true(預設值為 ``False``),則所有欄位將被標記為僅限關鍵" -"字。如果一個欄位被標記為僅限關鍵字,那麼唯一的影響是從僅限關鍵字欄位生成的 :" -"meth:`~object.__init__` 參數必須在呼叫 :meth:`!__init__` 時指定關鍵字。對資料" -"類別的任何其他方面都沒有影響。有關詳細資訊,請參閱 :term:`parameter` 詞彙表條" -"目。另請參閱 :const:`KW_ONLY` 部分。" +"*kw_only*:如果為真(預設值為 ``False``),則所有欄位都會被標記為僅限關鍵字。" +"如果一個欄位被標記為僅限關鍵字,那麼唯一的影響是:由該欄位生成的 :meth:" +"`~object.__init__` 參數,在呼叫 :meth:`!__init__` 時必須以關鍵字指定。詳情請" +"參閱 :term:`parameter` 詞彙表條目。另請參閱 :const:`KW_ONLY` 一節。" #: ../../library/dataclasses.rst:200 msgid "Keyword-only fields are not included in :attr:`!__match_args__`." msgstr "" #: ../../library/dataclasses.rst:204 -#, fuzzy msgid "" "*slots*: If true (the default is ``False``), :attr:`~object.__slots__` " "attribute will be generated and new class will be returned instead of the " "original one. If :attr:`!__slots__` is already defined in the class, then :" "exc:`TypeError` is raised." msgstr "" -"``slots``:如果為 true(預設為 ``False``),將生成 :attr:`~object.__slots__` " -"屬性並回傳新類別而不是原始類別。如果 :attr:`!__slots__` 已經在類別中定義," -"則 :exc:`TypeError` 被引發。" +"*slots*:如果為真(預設為 ``False``),將會生成 :attr:`~object.__slots__` 屬" +"性,並回傳新的類別而非原始類別。如果 :attr:`!__slots__` 已經在類別中定義,則" +"會引發 :exc:`TypeError`。" #: ../../library/dataclasses.rst:210 msgid "" @@ -425,7 +411,6 @@ msgid "" msgstr "" #: ../../library/dataclasses.rst:218 -#, fuzzy msgid "" "If a field name is already included in the :attr:`!__slots__` of a base " "class, it will not be included in the generated :attr:`!__slots__` to " @@ -434,14 +419,13 @@ msgid "" "`fields` instead. To be able to determine inherited slots, base class :attr:" "`!__slots__` may be any iterable, but *not* an iterator." msgstr "" -"如果欄位名稱已經包含在基底類別的 :attr:`!__slots__` 中,它將不會包含在生成" -"的 :attr:`!__slots__` 中以防止 :ref:`覆蓋它們 `。因此," -"不要使用 __slots__ 來檢索資料類別的欄位名稱。使用 :func:`fields` 代替。為了能" -"夠確定繼承的插槽,基底類別 :attr:`!__slots__` 可以是任何可疊代的,但*不是*疊" -"代器。" +"如果欄位名稱已經包含在基底類別的 :attr:`!__slots__` 中,為了防止\\ :ref:`覆蓋" +"它們 `,該名稱將不會包含在生成的 :attr:`!__slots__` " +"中。因此,請不要使用 :attr:`!__slots__` 來取得資料類別的欄位名稱,請改用 :" +"func:`fields`。為了能夠判斷繼承的插槽,基底類別的 :attr:`!__slots__` 可以是任" +"何可疊代物件,但\\ *不能*\\ 是疊代器。" #: ../../library/dataclasses.rst:228 -#, fuzzy msgid "" "*weakref_slot*: If true (the default is ``False``), add a slot named " "\"__weakref__\", which is required to make an instance :func:`weakref-able " @@ -449,11 +433,10 @@ msgid "" "specifying ``slots=True``." msgstr "" "*weakref_slot*:如果為真(預設為 ``False``),新增一個名為 \"__weakref__\" 的" -"插槽,這是使實例可弱引用所必需的。在沒有指定 ``slots=True`` 的情況下指定 " -"``weakref_slot=True`` 是錯誤的。" +"插槽,這是使實例\\ :func:`可弱引用 `\\ 所必需的。在未同時指定 " +"``slots=True`` 的情況下指定 ``weakref_slot=True`` 屬於錯誤用法。" #: ../../library/dataclasses.rst:236 -#, fuzzy msgid "" "``field``\\s may optionally specify a default value, using normal Python " "syntax::" @@ -468,7 +451,6 @@ msgid "" msgstr "" #: ../../library/dataclasses.rst:244 -#, fuzzy msgid "" "In this example, both :attr:`!a` and :attr:`!b` will be included in the " "added :meth:`~object.__init__` method, which will be defined as::" @@ -481,17 +463,15 @@ msgid "def __init__(self, a: int, b: int = 0):" msgstr "def __init__(self, a: int, b: int = 0):" #: ../../library/dataclasses.rst:249 -#, fuzzy msgid "" ":exc:`TypeError` will be raised if a field without a default value follows a " "field with a default value. This is true whether this occurs in a single " "class, or as a result of class inheritance." msgstr "" -":exc:`TypeError` 如果沒有預設值的欄位跟在具有預設值的欄位之後,將引發。無論這" -"發生在單個類別中還是作為類別繼承的結果,都是如此。" +"如果沒有預設值的欄位出現在有預設值的欄位之後,則會引發 :exc:`TypeError`。無論" +"這發生在單一類別中,還是類別繼承的結果,都是如此。" #: ../../library/dataclasses.rst:255 -#, fuzzy msgid "" "For common and simple use cases, no other functionality is required. There " "are, however, some dataclass features that require additional per-field " @@ -520,7 +500,6 @@ msgstr "" "c.mylist += [1, 2, 3]" #: ../../library/dataclasses.rst:268 -#, fuzzy msgid "" "As shown above, the :const:`MISSING` value is a sentinel object used to " "detect if some parameters are provided by the user. This sentinel is used " @@ -545,7 +524,6 @@ msgstr "" "呼叫本身會替換預設值的正常位置。" #: ../../library/dataclasses.rst:279 -#, fuzzy msgid "" "*default_factory*: If provided, it must be a zero-argument callable that " "will be called when a default value is needed for this field. Among other " @@ -558,7 +536,6 @@ msgstr "" "定 *default* 和 *default_factory* 是錯誤的。" #: ../../library/dataclasses.rst:285 -#, fuzzy msgid "" "*init*: If true (the default), this field is included as a parameter to the " "generated :meth:`~object.__init__` method." @@ -567,7 +544,6 @@ msgstr "" "方法的參數包含在內。" #: ../../library/dataclasses.rst:288 -#, fuzzy msgid "" "*repr*: If true (the default), this field is included in the string returned " "by the generated :meth:`~object.__repr__` method." @@ -576,7 +552,6 @@ msgstr "" "法回傳的字串中。" #: ../../library/dataclasses.rst:291 -#, fuzzy msgid "" "*hash*: This can be a bool or ``None``. If true, this field is included in " "the generated :meth:`~object.__hash__` method. If false, this field is " @@ -586,13 +561,13 @@ msgid "" "comparisons. Setting this value to anything other than ``None`` is " "discouraged." msgstr "" -"*hash*:這可以是 bool 或 ``None``。如果為真,則此欄位包含在生成的 :meth:" -"`__hash__` 方法中。如果 ``None``\\ (預設值),則使用\\ *比較*\\ 的值:這通常" -"是預期的行為。如果一個欄位用於比較,則應在雜湊中考慮該欄位。不鼓勵將此值設定" -"為 ``None`` 以外的任何值。" +"*hash*:這可以是 bool 或 ``None``。如果為真,則此欄位會包含在生成的 :meth:" +"`~object.__hash__` 方法中。如果為假,則此欄位會被排除在生成的 :meth:`~object." +"__hash__` 之外。如果為 ``None``\\ (預設值),則使用 *compare* 的值:這通常會" +"是預期的行為,因為如果一個欄位用於比較,通常也應該將它納入雜湊中。不建議將此" +"值設定為 ``None`` 以外的其他值。" #: ../../library/dataclasses.rst:299 -#, fuzzy msgid "" "One possible reason to set ``hash=False`` but ``compare=True`` would be if a " "field is expensive to compute a hash value for, that field is needed for " @@ -605,7 +580,6 @@ msgstr "" "值。即使一個欄位被排除在雜湊之外,它仍然會被用於比較。" #: ../../library/dataclasses.rst:305 -#, fuzzy msgid "" "*compare*: If true (the default), this field is included in the generated " "equality and comparison methods (:meth:`~object.__eq__`, :meth:`~object." @@ -615,7 +589,6 @@ msgstr "" "`~object.__eq__`、:meth:`~object.__gt__` 等)。" #: ../../library/dataclasses.rst:309 -#, fuzzy msgid "" "*metadata*: This can be a mapping or ``None``. ``None`` is treated as an " "empty dict. This value is wrapped in :func:`~types.MappingProxyType` to " @@ -624,13 +597,12 @@ msgid "" "mechanism. Multiple third-parties can each have their own key, to use as a " "namespace in the metadata." msgstr "" -"*metadata*:這可以是對映或無。 None 被視為空字典。此值包含在 :func:`~types." -"MappingProxyType` 中以使其成為只讀的,並暴露在 :class:`Field` 物件上。它根本" -"不被資料類別使用,而是作為第三方擴充機制提供的。多個第三方可以各自擁有自己的" -"密鑰,用作元資料中的命名空間。" +"*metadata*:這可以是對映或 ``None``。``None`` 會被視為空字典。此值會被包裝" +"在 :func:`~types.MappingProxyType` 中以使其成為唯讀,並公開在 :class:`Field` " +"物件上。Data Classes 完全不會使用它,它是作為第三方擴充機制提供的。多個第三方" +"可以各自擁有自己的鍵,在元資料中作為命名空間使用。" #: ../../library/dataclasses.rst:317 -#, fuzzy msgid "" "*kw_only*: If true, this field will be marked as keyword-only. This is used " "when the generated :meth:`~object.__init__` method's parameters are computed." @@ -647,7 +619,6 @@ msgid "*doc*: optional docstring for this field." msgstr "" #: ../../library/dataclasses.rst:329 -#, fuzzy msgid "" "If the default value of a field is specified by a call to :func:`!field`, " "then the class attribute for this field will be replaced by the specified " @@ -657,10 +628,10 @@ msgid "" "fields, just as if the default value itself were specified. For example, " "after::" msgstr "" -"如果欄位的預設值是透過呼叫 :func:`!field` 指定的,那麼該欄位的類別屬性將被指" -"定的 *default* 值替換。如果沒有提供 *default*,那麼類別屬性將被刪除。目的是" -"在 :func:`@dataclass ` 裝飾器運行後,類別屬性將全部包含欄位的預設" -"值,就像預設值本身已指定一樣。例如,在: ::" +"如果欄位的預設值是透過呼叫 :func:`!field` 指定的,那麼該欄位的類別屬性將被替" +"換為指定的 *default* 值。如果未提供 *default*,那麼該類別屬性將被刪除。其用意" +"是讓 :deco:`dataclass` 裝飾器執行後,類別屬性都會包含欄位的預設值,就像該預設" +"值本身已被指定一樣。舉例來說,在下列程式碼之後: ::" #: ../../library/dataclasses.rst:338 msgid "" @@ -679,17 +650,15 @@ msgstr "" " t: int = 20" #: ../../library/dataclasses.rst:345 -#, fuzzy msgid "" "The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!" "C.t` will be ``20``, and the class attributes :attr:`!C.x` and :attr:`!C.y` " "will not be set." msgstr "" -"類別屬性 :attr:`!C.z` 將為 ``10``,類別屬性 :attr:`!C.t` 將為 ``20``,類別屬" -"性 :attr:`!C.x` 和 :attr:`!C.y` 將不會放。" +"類別屬性 :attr:`!C.z` 將為 ``10``,類別屬性 :attr:`!C.t` 將為 ``20``,而類別" +"屬性 :attr:`!C.x` 和 :attr:`!C.y` 將不會被設定。" #: ../../library/dataclasses.rst:351 -#, fuzzy msgid "" ":class:`!Field` objects describe each defined field. These objects are " "created internally, and are returned by the :func:`fields` module-level " @@ -709,7 +678,6 @@ msgid ":attr:`!type`: The type of the field." msgstr ":attr:`!type`:欄位的型別。" #: ../../library/dataclasses.rst:358 -#, fuzzy msgid "" ":attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :" "attr:`!hash`, :attr:`!compare`, :attr:`!metadata`, and :attr:`!kw_only` have " @@ -720,7 +688,6 @@ msgstr "" "們在 :func:`field` 函式中的含義和值相同。" #: ../../library/dataclasses.rst:362 -#, fuzzy msgid "" "Other attributes may exist, but they are private and must not be inspected " "or relied on." @@ -736,7 +703,6 @@ msgid "" msgstr "" #: ../../library/dataclasses.rst:376 -#, fuzzy msgid "" "Returns a tuple of :class:`Field` objects that define the fields for this " "dataclass. Accepts either a dataclass, or an instance of a dataclass. " @@ -748,7 +714,6 @@ msgstr "" "``ClassVar`` 或 ``InitVar`` 的偽欄位。" #: ../../library/dataclasses.rst:383 -#, fuzzy msgid "" "Converts the dataclass *obj* to a dict (by using the factory function " "*dict_factory*). Each dataclass is converted to a dict of its fields, as " @@ -760,9 +725,8 @@ msgstr "" "遞迴到。其他物件使用 :func:`copy.deepcopy` 複製。" #: ../../library/dataclasses.rst:389 -#, fuzzy msgid "Example of using :func:`!asdict` on nested dataclasses::" -msgstr "在嵌套資料類別上使用 :func:`!asdict` 的範例: ::" +msgstr "在巢狀資料類別上使用 :func:`!asdict` 的範例: ::" #: ../../library/dataclasses.rst:391 msgid "" @@ -797,22 +761,19 @@ msgstr "" "assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}" #: ../../library/dataclasses.rst:406 ../../library/dataclasses.rst:426 -#, fuzzy msgid "To create a shallow copy, the following workaround may be used::" -msgstr "要建立淺複製,可以使用以下解決方法:" +msgstr "若要建立淺複製,可以使用以下替代方法: ::" #: ../../library/dataclasses.rst:408 msgid "{field.name: getattr(obj, field.name) for field in fields(obj)}" msgstr "{field.name: getattr(obj, field.name) for field in fields(obj)}" #: ../../library/dataclasses.rst:410 -#, fuzzy msgid "" ":func:`!asdict` raises :exc:`TypeError` if *obj* is not a dataclass instance." msgstr ":func:`!asdict` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" #: ../../library/dataclasses.rst:415 -#, fuzzy msgid "" "Converts the dataclass *obj* to a tuple (by using the factory function " "*tuple_factory*). Each dataclass is converted to a tuple of its field " @@ -840,7 +801,6 @@ msgid "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))" msgstr "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))" #: ../../library/dataclasses.rst:430 -#, fuzzy msgid "" ":func:`!astuple` raises :exc:`TypeError` if *obj* is not a dataclass " "instance." @@ -848,7 +808,6 @@ msgstr "" ":func:`!astuple` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" #: ../../library/dataclasses.rst:435 -#, fuzzy msgid "" "Creates a new dataclass with name *cls_name*, fields as defined in *fields*, " "base classes as given in *bases*, and initialized with a namespace as given " @@ -859,13 +818,13 @@ msgid "" "*slots*, and *weakref_slot* have the same meaning as they do in :deco:" "`dataclass`." msgstr "" -"建立一個名為 *cls_name* 的新資料類別,欄位在 *fields* 中定義,基底類別在 " -"*bases* 中給出,並使用 *namespace* 中給出的命名空間進行初始化。 ``fields`` 是" -"一個疊代器,其元素分別是 ``name``、``(name, type)`` 或 ``(name, type, " -"Field)``。如果只提供 ``name``,則 ``typing.Any`` 用於 ``type``。 ``init``、" -"``repr``、``eq``、``order``、``unsafe_hash``、``frozen``、``match_args``、" -"``kw_only`` 的值, ``slots`` 和 ``weakref_slot`` 與它們在 :func:`dataclass` 中" -"的含義相同。" +"建立一個名為 *cls_name* 的新資料類別,欄位定義於 *fields* 中,基底類別由 " +"*bases* 給定,並使用 *namespace* 中給定的命名空間進行初始化。*fields* 是一個" +"可疊代物件,其元素可以是 ``name``、``(name, type)`` 或 ``(name, type, " +"Field)``。如果只提供了 ``name``,則 ``type`` 會使用 :data:`typing.Any`。" +"*init*、*repr*、*eq*、*order*、*unsafe_hash*、*frozen*、*match_args*、" +"*kw_only*、*slots* 和 *weakref_slot* 的值,與它們在 :deco:`dataclass` 中的含" +"義相同。" #: ../../library/dataclasses.rst:445 msgid "" @@ -882,16 +841,15 @@ msgid "" msgstr "" #: ../../library/dataclasses.rst:454 -#, fuzzy msgid "" "This function is not strictly required, because any Python mechanism for " "creating a new class with :attr:`~object.__annotations__` can then apply " "the :deco:`dataclass` function to convert that class to a dataclass. This " "function is provided as a convenience. For example::" msgstr "" -"這個函式不是嚴格要求的,因為任何使用 :attr:`~object.__annotations__` 建立新類" -"別的 Python 機制都可以應用 :func:`dataclass` 函式將該類別轉換為資料類別。提供" -"此功能是為了方便。例如: ::" +"這個函式並非嚴格必要,因為任何使用 :attr:`~object.__annotations__` 建立新類別" +"的 Python 機制,都可以接著套用 :deco:`dataclass` 函式,將該類別轉換為資料類" +"別。提供此函式是為了方便起見。例如: ::" #: ../../library/dataclasses.rst:460 msgid "" @@ -947,7 +905,6 @@ msgstr "" "dataclass 的欄位則引發 :exc:`TypeError`。" #: ../../library/dataclasses.rst:487 -#, fuzzy msgid "" "The newly returned object is created by calling the :meth:`~object.__init__` " "method of the dataclass. This ensures that :meth:`__post_init__`, if " @@ -957,17 +914,15 @@ msgstr "" "保 :meth:`__post_init__`\\ (如果存在)也被呼叫。" #: ../../library/dataclasses.rst:491 -#, fuzzy msgid "" "Init-only variables without default values, if any exist, must be specified " "on the call to :func:`!replace` so that they can be passed to :meth:`!" "__init__` and :meth:`__post_init__`." msgstr "" -"沒有預設值的僅初始化變數(如果存在)必須在呼叫 :func:`replace` 時指定,以便它" -"們可以傳遞給 :meth:`__init__` 和 :meth:`__post_init__`。" +"沒有預設值的僅初始化變數(如果存在的話)必須在呼叫 :func:`!replace` 時指定," +"以便它們能被傳遞給 :meth:`!__init__` 和 :meth:`__post_init__`。" #: ../../library/dataclasses.rst:495 -#, fuzzy msgid "" "It is an error for *changes* to contain any fields that are defined as " "having ``init=False``. A :exc:`ValueError` will be raised in this case." @@ -976,7 +931,6 @@ msgstr "" "發 :exc:`ValueError`。" #: ../../library/dataclasses.rst:499 -#, fuzzy msgid "" "Be forewarned about how ``init=False`` fields work during a call to :func:`!" "replace`. They are not copied from the source object, but rather are " @@ -1008,7 +962,6 @@ msgstr "" "名 `)或一個實例則回傳 ``True``,否則回傳 ``False``。" #: ../../library/dataclasses.rst:516 -#, fuzzy msgid "" "If you need to know if a class is an instance of a dataclass (and not a " "dataclass itself), then add a further check for ``not isinstance(obj, " @@ -1026,12 +979,10 @@ msgstr "" " return is_dataclass(obj) and not isinstance(obj, type)" #: ../../library/dataclasses.rst:525 -#, fuzzy msgid "A sentinel value signifying a missing default or default_factory." msgstr "表示缺少 default 或 default_factory 的標記值。" #: ../../library/dataclasses.rst:529 -#, fuzzy msgid "" "A sentinel value used as a type annotation. Any fields after a pseudo-field " "with the type of :const:`!KW_ONLY` are marked as keyword-only fields. Note " @@ -1047,7 +998,6 @@ msgstr "" "表示 :meth:`~object.__init__` 參數,在實例化類別時必須將其指定為關鍵字。" #: ../../library/dataclasses.rst:538 -#, fuzzy msgid "" "In this example, the fields ``y`` and ``z`` will be marked as keyword-only " "fields::" @@ -1074,29 +1024,26 @@ msgstr "" "p = Point(0, y=1.5, z=2.0)" #: ../../library/dataclasses.rst:549 -#, fuzzy msgid "" "In a single dataclass, it is an error to specify more than one field whose " "type is :const:`!KW_ONLY`." msgstr "在單個資料類別中,指定多個型別為 :const:`!KW_ONLY` 的欄位是錯誤的。" #: ../../library/dataclasses.rst:556 -#, fuzzy msgid "" "Raised when an implicitly defined :meth:`~object.__setattr__` or :meth:" "`~object.__delattr__` is called on a dataclass which was defined with " "``frozen=True``. It is a subclass of :exc:`AttributeError`." msgstr "" -"當在使用 frozen=True 定義的資料類別上呼叫隱式定義的 :meth:`__setattr__` 或 :" -"meth:`__delattr__` 時引發。它是 :exc:`AttributeError` 的子類別。" +"當在以 ``frozen=True`` 定義的資料類別上呼叫隱式定義的 :meth:`~object." +"__setattr__` 或 :meth:`~object.__delattr__` 時,會引發此例外。它是 :exc:" +"`AttributeError` 的子類別。" #: ../../library/dataclasses.rst:563 -#, fuzzy msgid "Post-init processing" msgstr "後初始化處理" #: ../../library/dataclasses.rst:567 -#, fuzzy msgid "" "When defined on the class, it will be called by the generated :meth:`~object." "__init__`, normally as :meth:`!self.__post_init__`. However, if any " @@ -1105,14 +1052,12 @@ msgid "" "__init__` method is generated, then :meth:`!__post_init__` will not " "automatically be called." msgstr "" -"生成的 :meth:`~object.__init__` 程式碼將呼叫一個名為 :meth:`!self." -"__post_init__` 的方法,如果 :meth:`!__post_init__` 是在類別上定義的。它通常被" -"稱為 ``self.!__post_init__()``。但是,如果定義了任何 ``InitVar`` 欄位,它們也" -"將按照它們在類別中定義的順序傳遞給 :meth:`!__post_init__` 。如果沒有生成 :" -"meth:`!__init__` 方法,那麼 :meth:`!__post_init__` 將不會被自動呼叫。" +"當它在類別上被定義時,會被生成的 :meth:`~object.__init__` 呼叫,通常是以 :" +"meth:`!self.__post_init__` 的形式呼叫。但是,如果定義了任何 ``InitVar`` 欄" +"位,它們也會依照在類別中定義的順序被傳遞給 :meth:`!__post_init__`。如果沒有生" +"成 :meth:`!__init__` 方法,那麼 :meth:`!__post_init__` 將不會被自動呼叫。" #: ../../library/dataclasses.rst:574 -#, fuzzy msgid "" "Among other uses, this allows for initializing field values that depend on " "one or more other fields. For example::" @@ -1139,16 +1084,15 @@ msgstr "" " self.c = self.a + self.b" #: ../../library/dataclasses.rst:586 -#, fuzzy msgid "" "The :meth:`~object.__init__` method generated by :deco:`dataclass` does not " "call base class :meth:`!__init__` methods. If the base class has an :meth:`!" "__init__` method that has to be called, it is common to call this method in " "a :meth:`__post_init__` method::" msgstr "" -":func:`@dataclass ` 生成的 :meth:`~object.__init__` 方法不呼叫基底" -"類別 :meth:`!__init__` 方法。如果基底類別有一個必須呼叫的 :meth:`!__init__` " -"方法,通常在 :meth:`__post_init__` 方法中呼叫此方法: ::" +"由 :deco:`dataclass` 生成的 :meth:`~object.__init__` 方法不會呼叫基底類別的 :" +"meth:`!__init__` 方法。如果基底類別有一個必須被呼叫的 :meth:`!__init__` 方" +"法,通常會在 :meth:`__post_init__` 方法中呼叫此方法: ::" #: ../../library/dataclasses.rst:591 msgid "" @@ -1177,7 +1121,6 @@ msgstr "" " super().__init__(self.side, self.side)" #: ../../library/dataclasses.rst:603 -#, fuzzy msgid "" "Note, however, that in general the dataclass-generated :meth:`!__init__` " "methods don't need to be called, since the derived dataclass will take care " @@ -1187,7 +1130,6 @@ msgstr "" "類別將負責初始化作為資料類別本身的任何基底類別的所有欄位。" #: ../../library/dataclasses.rst:607 -#, fuzzy msgid "" "See the section below on init-only variables for ways to pass parameters to :" "meth:`!__post_init__`. Also see the warning about how :func:`replace` " @@ -1201,7 +1143,6 @@ msgid "Class variables" msgstr "類別變數" #: ../../library/dataclasses.rst:616 -#, fuzzy msgid "" "One of the few places where :deco:`dataclass` actually inspects the type of " "a field is to determine if a field is a class variable as defined in :pep:" @@ -1210,19 +1151,17 @@ msgid "" "as a field and is ignored by the dataclass mechanisms. Such ``ClassVar`` " "pseudo-fields are not returned by the module-level :func:`fields` function." msgstr "" -":func:`@dataclass ` 實際檢查欄位型別的少數地方之一是確定欄位是否" -"是 :pep:`526` 中定義的類別變數。它透過檢查欄位的型別是否為 :data:`typing." -"ClassVar` 來做到這一點。如果一個欄位是一個 ``ClassVar``,它就被排除在考慮之" -"外,並被資料類別機制忽略。模組級 :func:`fields` 函式不會回傳此類別 " -"``ClassVar`` 偽欄位。" +":deco:`dataclass` 實際檢查欄位型別的少數幾個地方之一,就是用來判斷欄位是否" +"為 :pep:`526` 中定義的類別變數。它透過檢查欄位的型別是否為 :data:`typing." +"ClassVar` 來達成這一點。如果一個欄位是 ``ClassVar``,它就會被排除在欄位考量之" +"外,並被資料類別機制忽略。這類 ``ClassVar`` 偽欄位不會被模組層級的 :func:" +"`fields` 函式回傳。" #: ../../library/dataclasses.rst:627 -#, fuzzy msgid "Init-only variables" msgstr "僅初始化變數" #: ../../library/dataclasses.rst:629 -#, fuzzy msgid "" "Another place where :deco:`dataclass` inspects a type annotation is to " "determine if a field is an init-only variable. It does this by seeing if " @@ -1233,15 +1172,14 @@ msgid "" "`~object.__init__` method, and are passed to the optional :meth:" "`__post_init__` method. They are not otherwise used by dataclasses." msgstr "" -":func:`dataclass` 檢查型別註解的另一個地方是確定欄位是否是僅初始化變數。它通" -"過查看欄位的型別是否為 ``dataclasses.InitVar`` 型別來執行此操作。如果一個欄位" -"是一個 ``InitVar``,它被認為是一個偽欄位,稱為 init-only 欄位。由於它不是真正" -"的欄位,因此它不會由模組級 fields 函式回傳。 Init-only 欄位作為參數新增到生成" -"的 :meth:`~object.__init__` 方法,並傳遞給可選的 :meth:`__post_init__` 方法。" -"它們不被資料類別使用。" +":deco:`dataclass` 檢查型別註釋的另一個地方,是用來判斷欄位是否為僅初始化變" +"數。它透過檢查欄位的型別是否為 :class:`InitVar` 型別來達成這一點。如果一個欄" +"位是 :class:`InitVar`,則會被視為一個稱為僅初始化欄位的偽欄位。由於它不是真正" +"的欄位,因此不會被模組層級的 :func:`fields` 函式回傳。僅初始化欄位會被新增為" +"生成的 :meth:`~object.__init__` 方法的參數,並傳遞給可選的 :meth:" +"`__post_init__` 方法。除此之外,它們不會被資料類別使用。" #: ../../library/dataclasses.rst:639 -#, fuzzy msgid "" "For example, suppose a field will be initialized from a database, if a value " "is not provided when creating the class::" @@ -1274,7 +1212,6 @@ msgstr "" "c = C(10, database=my_database)" #: ../../library/dataclasses.rst:654 -#, fuzzy msgid "" "In this case, :func:`fields` will return :class:`Field` objects for :attr:`!" "i` and :attr:`!j`, but not for :attr:`!database`." @@ -1287,7 +1224,6 @@ msgid "Frozen instances" msgstr "凍結實例" #: ../../library/dataclasses.rst:662 -#, fuzzy msgid "" "It is not possible to create truly immutable Python objects. However, by " "passing ``frozen=True`` to the :deco:`dataclass` decorator you can emulate " @@ -1295,27 +1231,25 @@ msgid "" "__setattr__` and :meth:`~object.__delattr__` methods to the class. These " "methods will raise a :exc:`FrozenInstanceError` when invoked." msgstr "" -"不可能建立真正不可變的 Python 物件。但是,透過將 ``frozen=True`` 傳遞給 :" -"func:`@dataclass ` 裝飾器,你可以模擬不變性。在這種情況下,資料類" -"別將向類別新增 :meth:`~object.__setattr__` 和 :meth:`~object.__delattr__` 方" -"法。這些方法在叫用時會引發 :exc:`FrozenInstanceError`。" +"建立真正不可變的 Python 物件是不可能的。但是,透過將 ``frozen=True`` 傳遞給 :" +"deco:`dataclass` 裝飾器,你可以模擬不變性。在這種情況下,資料類別會為該類別新" +"增 :meth:`~object.__setattr__` 和 :meth:`~object.__delattr__` 方法。這些方法" +"在被呼叫時會引發 :exc:`FrozenInstanceError`。" #: ../../library/dataclasses.rst:668 -#, fuzzy msgid "" "There is a tiny performance penalty when using ``frozen=True``: :meth:" "`~object.__init__` cannot use simple assignment to initialize fields, and " "must use :meth:`!object.__setattr__`." msgstr "" -"使用 ``frozen=True`` 時有一個微小的性能損失::meth:`~object.__init__` 不能使" -"用簡單賦值來初始化欄位,必須使用 :meth:`!object.__setattr__`。" +"使用 ``frozen=True`` 時會有微小的效能損失::meth:`~object.__init__` 無法使用" +"簡單賦值來初始化欄位,必須改用 :meth:`!object.__setattr__`。" #: ../../library/dataclasses.rst:677 msgid "Inheritance" msgstr "繼承" #: ../../library/dataclasses.rst:679 -#, fuzzy msgid "" "When the dataclass is being created by the :deco:`dataclass` decorator, it " "looks through all of the class's base classes in reverse MRO (that is, " @@ -1326,11 +1260,11 @@ msgid "" "ordered mapping of fields. Because the fields are in insertion order, " "derived classes override base classes. An example::" msgstr "" -"當 :func:`@dataclass ` 裝飾器建立資料類別時,它會以反向 MRO(即" -"從 :class:`object` 開始)查看該類別的所有基底類別,並且對於它找到的每個資料類" -"別,將該基底類別中的欄位新增到欄位的有序對映中。新增所有基底類別欄位後,它會" -"將自己的欄位新增到有序對映中。所有生成的方法都將使用這種組合的、計算的有序欄" -"位對映。因為欄位是按插入順序排列的,所以衍生類別會覆蓋基底類別。一個例子: ::" +"當 :deco:`dataclass` 裝飾器建立資料類別時,它會以反向 MRO(也就是從 :class:" +"`object` 開始)檢視該類別的所有基底類別,並針對它找到的每個資料類別,將該基底" +"類別的欄位新增到欄位的有序對映中。新增完所有基底類別的欄位後,它會將自己的欄" +"位新增到這個有序對映中。所有生成的方法都會使用這個組合、計算後的有序欄位對" +"映。由於欄位是依插入順序排列,因此衍生類別會覆蓋基底類別。舉例來說: ::" #: ../../library/dataclasses.rst:689 msgid "" @@ -1355,7 +1289,6 @@ msgstr "" " x: int = 15" #: ../../library/dataclasses.rst:699 -#, fuzzy msgid "" "The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. " "The final type of :attr:`!x` is :class:`int`, as specified in class :class:`!" @@ -1365,7 +1298,6 @@ msgstr "" "型別是 :class:`int`,如類別 :class:`!C` 中指定的那樣。" #: ../../library/dataclasses.rst:702 -#, fuzzy msgid "" "The generated :meth:`~object.__init__` method for :class:`!C` will look " "like::" @@ -1376,24 +1308,21 @@ msgid "def __init__(self, x: int = 15, y: int = 0, z: int = 10):" msgstr "def __init__(self, x: int = 15, y: int = 0, z: int = 10):" #: ../../library/dataclasses.rst:707 -#, fuzzy msgid "Re-ordering of keyword-only parameters in :meth:`!__init__`" msgstr ":meth:`!__init__` 中僅關鍵字參數的重新排序" #: ../../library/dataclasses.rst:709 -#, fuzzy msgid "" "After the parameters needed for :meth:`~object.__init__` are computed, any " "keyword-only parameters are moved to come after all regular (non-keyword-" "only) parameters. This is a requirement of how keyword-only parameters are " "implemented in Python: they must come after non-keyword-only parameters." msgstr "" -"在計算 :meth:`__init__` 所需的參數後,任何僅關鍵字參數都將移動到所有常規(非" -"僅關鍵字)參數之後。這是如何在 Python 中實作僅關鍵字參數的要求:它們必須位於" -"非僅關鍵字參數之後。" +"在計算出 :meth:`~object.__init__` 所需的參數後,任何僅限關鍵字參數都會被移到" +"所有常規(非僅限關鍵字)參數之後。這是 Python 中僅限關鍵字參數實作方式的要" +"求:它們必須排在非僅限關鍵字參數之後。" #: ../../library/dataclasses.rst:715 -#, fuzzy msgid "" "In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are " "keyword-only fields, and :attr:`!Base.x` and :attr:`!D.z` are regular " @@ -1429,7 +1358,6 @@ msgstr "" " t: int = field(kw_only=True, default=0)" #: ../../library/dataclasses.rst:730 -#, fuzzy msgid "The generated :meth:`!__init__` method for :class:`!D` will look like::" msgstr "為 :class:`!D` 生成的 :meth:`!__init__` 方法將如下所示: ::" @@ -1442,7 +1370,6 @@ msgstr "" "int = 0):" #: ../../library/dataclasses.rst:734 -#, fuzzy msgid "" "Note that the parameters have been re-ordered from how they appear in the " "list of fields: parameters derived from regular fields are followed by " @@ -1452,7 +1379,6 @@ msgstr "" "跟從僅關鍵字欄位衍生的參數。" #: ../../library/dataclasses.rst:738 -#, fuzzy msgid "" "The relative ordering of keyword-only parameters is maintained in the re-" "ordered :meth:`!__init__` parameter list." @@ -1463,21 +1389,19 @@ msgid "Default factory functions" msgstr "預設工廠函式" #: ../../library/dataclasses.rst:745 -#, fuzzy msgid "" "If a :func:`field` specifies a *default_factory*, it is called with zero " "arguments when a default value for the field is needed. For example, to " "create a new instance of a list, use::" msgstr "" -"如果 :func:`field` 指定了 *default_factory*,當需要該欄位的預設值時,它會以零" -"引數呼叫。例如,要建立列表的新實例,請使用: ::" +"如果 :func:`field` 指定了 *default_factory*,那麼在該欄位需要預設值時,它會以" +"零引數的方式被呼叫。舉例來說,若要建立一個新的 list 實例,可以使用: ::" #: ../../library/dataclasses.rst:749 msgid "mylist: list = field(default_factory=list)" msgstr "mylist: list = field(default_factory=list)" #: ../../library/dataclasses.rst:751 -#, fuzzy msgid "" "If a field is excluded from :meth:`~object.__init__` (using ``init=False``) " "and the field also specifies *default_factory*, then the default factory " @@ -1485,16 +1409,16 @@ msgid "" "function. This happens because there is no other way to give the field an " "initial value." msgstr "" -"如果一個欄位從 :meth:`~object.__init__` 中排除(使用 ``init=False``)並且該欄" -"位還指定了 ``default_factory``,那麼預設工廠函式將始終從生成的 :meth:" -"`__init__ 中呼叫`功能。發生這種情況是因為沒有其他方法可以為該欄位賦予初始值。" +"如果某個欄位被排除在 :meth:`~object.__init__` 之外(使用 ``init=False``),且" +"該欄位又指定了 *default_factory*,那麼預設工廠函式就一定會在生成的 :meth:`!" +"__init__` 函式中被呼叫。之所以會這樣,是因為沒有其他方法可以為該欄位提供初始" +"值。" #: ../../library/dataclasses.rst:758 msgid "Mutable default values" msgstr "可變預設值" #: ../../library/dataclasses.rst:760 -#, fuzzy msgid "" "Python stores default member variable values in class attributes. Consider " "this example, not using dataclasses::" @@ -1528,7 +1452,6 @@ msgstr "" "assert o1.x is o2.x" #: ../../library/dataclasses.rst:775 -#, fuzzy msgid "" "Note that the two instances of class :class:`!C` share the same class " "variable :attr:`!x`, as expected." @@ -1537,7 +1460,6 @@ msgstr "" "那樣。" #: ../../library/dataclasses.rst:778 -#, fuzzy msgid "Using dataclasses, *if* this code was valid::" msgstr "使用資料類別,*如果*\\ 此程式碼有效: ::" @@ -1580,7 +1502,6 @@ msgstr "" "assert D().x is D().x" #: ../../library/dataclasses.rst:797 -#, fuzzy msgid "" "This has the same issue as the original example using class :class:`!C`. " "That is, two instances of class :class:`!D` that do not specify a value for :" @@ -1592,15 +1513,15 @@ msgid "" "is that if a value is unhashable, it is mutable. This is a partial " "solution, but it does protect against many common errors." msgstr "" -"這與使用類別 :class:`!C` 的原始示例存在相同的問題。也就是說,類別 :class:`!" -"D` 的兩個實例在建立類別實例時沒有為 :attr:`!x` 指定值,它們將共享 :attr:`!x` " -"的同一個副本。因為資料類別只是使用普通的 Python 類別建立,所以它們也有這種行" -"為。資料類別沒有通用的方法來檢測這種情況。相反,如果 :func:`dataclass` 裝飾器" -"檢測到不可雜湊的預設參數,它將引發 :exc:`TypeError`。假設是如果一個值是不可散" -"列的,那麼它就是可變的。這是一個部分解決方案,但它確實可以防止許多常見錯誤。" +"這與使用類別 :class:`!C` 的原始範例有相同的問題。也就是說,類別 :class:`!D` " +"的兩個實例,如果在建立類別實例時沒有為 :attr:`!x` 指定值,將會共享同一份 :" +"attr:`!x` 的副本。因為資料類別只是使用一般的 Python 類別建立方式,所以它們也" +"會有這種行為。Data Classes 沒有通用的方法可以偵測到這種情況。取而代之,如果 :" +"deco:`dataclass` 裝飾器偵測到不可雜湊的預設參數,就會引發 :exc:`ValueError`。" +"這裡的假設是,如果一個值是不可雜湊的,那麼它就是可變的。這只是一個部分解決方" +"案,但確實能防止許多常見錯誤。" #: ../../library/dataclasses.rst:808 -#, fuzzy msgid "" "Using default factory functions is a way to create new instances of mutable " "types as default values for fields::" @@ -1621,7 +1542,6 @@ msgstr "" "assert D().x is not D().x" #: ../../library/dataclasses.rst:817 -#, fuzzy msgid "" "Instead of looking for and disallowing objects of type :class:`list`, :class:" "`dict`, or :class:`set`, unhashable objects are now not allowed as default " @@ -1631,12 +1551,10 @@ msgstr "" "在不允許使用不可雜湊的物件作為預設值。不可雜湊性用於近似可變性。" #: ../../library/dataclasses.rst:824 -#, fuzzy msgid "Descriptor-typed fields" msgstr "描述器型別的欄位" #: ../../library/dataclasses.rst:826 -#, fuzzy msgid "" "Fields that are assigned :ref:`descriptor objects ` as their " "default value have the following special behaviors:" @@ -1644,7 +1562,6 @@ msgstr "" "指定為\\ :ref:`描述器物件 `\\ 作為預設值的欄位具有以下特殊行為:" #: ../../library/dataclasses.rst:829 -#, fuzzy msgid "" "The value for the field passed to the dataclass's :meth:`~object.__init__` " "method is passed to the descriptor's :meth:`~object.__set__` method rather " @@ -1654,7 +1571,6 @@ msgstr "" "`~object.__set__` 方法,而不是覆蓋描述器物件。" #: ../../library/dataclasses.rst:833 -#, fuzzy msgid "" "Similarly, when getting or setting the field, the descriptor's :meth:" "`~object.__get__` or :meth:`!__set__` method is called rather than returning " @@ -1664,7 +1580,6 @@ msgstr "" "__set__` 方法,而不是回傳或覆蓋描述器物件。" #: ../../library/dataclasses.rst:837 -#, fuzzy msgid "" "To determine whether a field contains a default value, :deco:`dataclass` " "will call the descriptor's :meth:`!__get__` method using its class access " @@ -1673,11 +1588,11 @@ msgid "" "hand, if the descriptor raises :exc:`AttributeError` in this situation, no " "default value will be provided for the field." msgstr "" -"為了確定一個欄位是否包含預設值,:func:`@dataclass ` 將使用其類別存" -"取形式呼叫描述器的 :meth:`!__get__` 方法(即 ``descriptor.__get__(obj=None, " -"type=cls)``。如果在這種情況下,描述器回傳一個值,它將用作欄位的預設值。另一方" -"面,如果描述器在這種情況下引發 :exc:`AttributeError`,則不會為該欄位提供預設" -"值。" +"為了判斷一個欄位是否包含預設值,:deco:`dataclass` 會使用其類別存取形式來呼叫" +"描述器的 :meth:`!__get__` 方法(即 ``descriptor.__get__(obj=None, " +"type=cls)``)。如果在這種情況下描述器回傳了一個值,它就會被用作該欄位的預設" +"值。反之,如果描述器在這種情況下引發 :exc:`AttributeError`,則不會為該欄位提" +"供預設值。" #: ../../library/dataclasses.rst:847 msgid "" @@ -1734,7 +1649,6 @@ msgstr "" "print(i.quantity_on_hand) # 2" #: ../../library/dataclasses.rst:872 -#, fuzzy msgid "" "Note that if a field is annotated with a descriptor type, but is not " "assigned a descriptor object as its default value, the field will act like a " diff --git a/library/datetime.po b/library/datetime.po index 485959dcf0..7575e06748 100644 --- a/library/datetime.po +++ b/library/datetime.po @@ -2218,6 +2218,10 @@ msgid "" "functions on many platforms, this method may raise :exc:`OverflowError` or :" "exc:`OSError` for times far in the past or far in the future." msgstr "" +"Naive :class:`.datetime` 實例會被視為代表本地時間,而此方法依賴平台的 C 函式" +"來執行轉換。由於 :class:`!datetime` 支援比許多平台上的 C 函式更廣的數值範圍," +"對於過去或未來過於久遠的時間,此方法可能會引發 :exc:`OverflowError` 或 :exc:" +"`OSError`。" #: ../../library/datetime.rst:1540 msgid "" @@ -2258,7 +2262,7 @@ msgstr "" msgid "" "This method no longer relies on the platform C :c:func:`mktime` function to " "perform conversions." -msgstr "" +msgstr "此方法不再依賴平台的 C :c:func:`mktime` 函式來執行轉換。" #: ../../library/datetime.rst:1572 msgid "" diff --git a/library/dialog.po b/library/dialog.po index 6b054da65d..6efd40d15d 100644 --- a/library/dialog.po +++ b/library/dialog.po @@ -39,6 +39,7 @@ msgid "" "Prompt the user to enter a value of the desired type and return it, or " "``None`` if the dialog is cancelled." msgstr "" +"提示使用者輸入所需型別的值並回傳該值,如果對話框被取消則回傳 ``None``。" #: ../../library/dialog.rst:25 msgid "" @@ -49,6 +50,11 @@ msgid "" "value. :func:`askstring` also accepts *show*, a character used to mask the " "entered text, for example ``'*'`` to hide a password." msgstr "" +"*title* 為對話框標題,*prompt* 為顯示在輸入欄位上方的訊息。*initialvalue* 為" +"輸入欄位中最初放置的值。*parent* 為顯示對話框的父視窗。:func:`askinteger` " +"和 :func:`askfloat` 也接受 *minvalue* 和 *maxvalue*,用於限制可接受值的範" +"圍。:func:`askstring` 還接受 *show*,這是一個用於遮蔽輸入文字的字元,例如用 " +"``'*'`` 來隱藏密碼。" #: ../../library/dialog.rst:35 msgid "" @@ -56,11 +62,13 @@ msgid "" "and returns once the user closes it; the entered value is then available in " "the :attr:`!result` attribute." msgstr "" +"自訂對話框的基底類別。將其實例化後會以互動 (modal) 方式顯示對話框,並在使用者" +"關閉對話框後才回傳;使用者輸入的值隨後可透過 :attr:`!result` 屬性取得。" #: ../../library/dialog.rst:41 msgid "" "The value produced by :meth:`apply`, or ``None`` if the dialog was cancelled." -msgstr "" +msgstr ":meth:`apply` 所產生的值,如果對話框被取消則為 ``None``。" #: ../../library/dialog.rst:46 msgid "" @@ -81,6 +89,9 @@ msgid "" "open. The default implementation always returns true; override it to check " "the input." msgstr "" +"驗證使用者輸入的資料。如果資料有效則回傳 true,此時對話框會繼續執行 :meth:" +"`apply`;回傳 false 則保持對話框開啟。預設實作總是回傳 true;覆寫此方法以檢查" +"輸入內容。" #: ../../library/dialog.rst:64 msgid "" @@ -89,12 +100,15 @@ msgid "" "the dialog is destroyed. The default implementation does nothing; override " "it to act on or store the result." msgstr "" +"處理使用者輸入的資料,例如將其儲存到 :attr:`!result` 屬性中。此方法會在 :" +"meth:`validate` 成功之後、對話框被銷毀之前呼叫。預設實作不執行任何動作;覆寫" +"此方法以處理或儲存結果。" #: ../../library/dialog.rst:73 msgid "" "Destroy the dialog window, clearing the reference to the widget that had the " "initial focus." -msgstr "" +msgstr "銷毀對話框視窗,並清除對最初獲得焦點之元件的參照。" #: ../../library/dialog.rst:79 msgid "" @@ -105,12 +119,16 @@ msgid "" "through the window manager, *title* the window title, and *class_* the Tk " "class name of the window." msgstr "" +"一個簡單的互動 (modal) 對話框,會在一列按鈕上方顯示訊息 *text*,這些按鈕的標" +"籤由 *buttons* 給定,並回傳使用者按下之按鈕的索引。*default* 為按下 Return 鍵" +"時所啟動按鈕的索引,*cancel* 為透過視窗管理員關閉視窗時回傳的索引,*title* 為" +"視窗標題,*class_* 為該視窗的 Tk 類別名稱。" #: ../../library/dialog.rst:88 msgid "" "Display the dialog, wait until the user presses a button or closes the " "window, and return the index of the chosen button." -msgstr "" +msgstr "顯示對話框,等待使用者按下按鈕或關閉視窗,然後回傳所選按鈕的索引。" #: ../../library/dialog.rst:94 msgid ":mod:`!tkinter.filedialog` --- File selection dialogs" @@ -128,7 +146,7 @@ msgstr "" #: ../../library/dialog.rst:107 msgid "Native load/save dialogs" -msgstr "" +msgstr "原生的載入/儲存對話框" #: ../../library/dialog.rst:109 msgid "" @@ -180,6 +198,10 @@ msgid "" "vary between platforms and Tk versions, so test the result for truth rather " "than comparing it with a specific value." msgstr "" +"以下函式被呼叫時,會建立一個互動 (modal)、具原生外觀風格的對話框,等待使用者" +"做出選擇後回傳該選擇。實際的回傳值依函式而定(詳見下文);當對話框被取消時," +"回傳值為空字串、空 tuple 或 ``None``。這個空值的確切型別可能因平台和 Tk 版本" +"而有所不同,因此請以真值測試結果,而不要與特定值進行比較。" #: ../../library/dialog.rst:142 msgid "" @@ -188,6 +210,10 @@ msgid "" "a list of the opened file objects, or an empty tuple if cancelled. The files " "are opened in mode *mode* (read-only ``'r'`` by default)." msgstr "" +"建立一個 :class:`Open` 對話框。:func:`askopenfile` 會回傳已開啟的檔案物件,如" +"果對話框被取消則回傳 ``None``。:func:`askopenfiles` 會回傳已開啟檔案物件的 " +"list,如果取消則回傳空 tuple。這些檔案會以模式 *mode* 開啟(預設為唯讀的 " +"``'r'``)。" #: ../../library/dialog.rst:151 msgid "" @@ -195,6 +221,8 @@ msgid "" "``None`` if the dialog is cancelled. The file is opened in mode *mode* " "(``'w'`` by default)." msgstr "" +"建立一個 :class:`SaveAs` 對話框,並回傳已開啟的檔案物件,如果對話框被取消則回" +"傳 ``None``。此檔案會以模式 *mode* 開啟(預設為 ``'w'``)。" #: ../../library/dialog.rst:158 msgid "" @@ -203,12 +231,17 @@ msgid "" "`askopenfilenames` returns a tuple of the selected filenames, or an empty " "tuple if cancelled." msgstr "" +"建立一個 :class:`Open` 對話框。:func:`askopenfilename` 會以字串形式回傳所選取" +"的檔案名稱,如果對話框被取消則回傳空字串。:func:`askopenfilenames` 會回傳所選" +"取檔案名稱的 tuple,如果取消則回傳空 tuple。" #: ../../library/dialog.rst:166 msgid "" "Create a :class:`SaveAs` dialog and return the selected filename as a " "string, or an empty string if the dialog is cancelled." msgstr "" +"建立一個 :class:`SaveAs` 對話框,並以字串形式回傳所選取的檔案名稱,如果對話框" +"被取消則回傳空字串。" #: ../../library/dialog.rst:171 msgid "" @@ -217,12 +250,15 @@ msgid "" "*mustexist* - if true, the user may only select an existing directory (false " "by default)." msgstr "" +"提示使用者選擇一個目錄,並以字串形式回傳其路徑,如果對話框被取消則回傳空字" +"串。額外的關鍵字選項:*mustexist* - 如果為 true,使用者只能選擇已存在的目錄" +"(預設為 false)。" #: ../../library/dialog.rst:180 msgid "" "The above three classes provide native dialog windows for loading and saving " "files and for selecting a directory." -msgstr "" +msgstr "上述三個類別提供了用於載入和儲存檔案,以及選擇目錄的原生對話框視窗。" #: ../../library/dialog.rst:183 msgid "**Convenience classes**" @@ -290,6 +326,8 @@ msgid "" "accepts the selection and closes the dialog; :class:`LoadFileDialog` and :" "class:`SaveFileDialog` override it to check the selection first." msgstr "" +"當使用者確認目前的選擇時呼叫。基底實作會接受該選擇並關閉對話框;:class:" +"`LoadFileDialog` 和 :class:`SaveFileDialog` 會覆寫此方法以先檢查選擇內容。" #: ../../library/dialog.rst:244 msgid "Exit dialog returning filename, if any." @@ -358,12 +396,14 @@ msgid "" "The :mod:`!tkinter.dialog` module provides a simple modal dialog box built " "on the classic (non-themed) Tk widgets." msgstr "" +":mod:`!tkinter.dialog` 模組提供一個簡單的互動 (modal) 對話框,其建構於傳統" +"(非主題化)Tk 元件之上。" #: ../../library/dialog.rst:311 msgid "" "The name of a bitmap (``'questhead'``) suitable for use as the *bitmap* of " "a :class:`Dialog`." -msgstr "" +msgstr "適合用作 :class:`Dialog` 之 *bitmap* 的點陣圖 (``'questhead'``) 名稱。" #: ../../library/dialog.rst:316 msgid "" @@ -375,12 +415,19 @@ msgid "" "*strings* (the sequence of button labels). After construction, the :attr:`!" "num` attribute holds the index of the button the user pressed." msgstr "" +"顯示一個由傳統(非主題化)Tk 元件建立的互動 (modal) 對話框,並等待使用者按下" +"其中一個按鈕。透過 *cnf* 或關鍵字引數提供的選項包括:*title* (視窗標題)、" +"*text* (訊息內容)、*bitmap* (圖示,預設為 :data:`DIALOG_ICON`)、" +"*default* (預設按鈕的索引)和 *strings* (按鈕標籤的序列)。建構完成後,:" +"attr:`!num` 屬性會保存使用者按下之按鈕的索引。" #: ../../library/dialog.rst:327 msgid "" "Do nothing. The dialog window is destroyed automatically before the " "constructor returns, so there is nothing left for this method to do." msgstr "" +"不做任何事。對話框視窗在建構函式回傳前就會自動銷毀,因此這個方法沒有任何工作" +"要做。" #: ../../library/dialog.rst:334 msgid "Modules :mod:`tkinter.messagebox`, :ref:`tut-files`" diff --git a/library/difflib.po b/library/difflib.po index a3c3c51249..f27ef3f9e7 100644 --- a/library/difflib.po +++ b/library/difflib.po @@ -34,6 +34,11 @@ msgid "" "context and unified diffs -- formats produced by tools like :manpage:`diff " "` and :manpage:`git diff `." msgstr "" +"此模組提供用於比較序列的類別和函式。其中大多數用於比較文字行的序列(例如字串" +"串列,或\\ :term:`檔案物件 `),並產生\\ :dfn:`diff`\\ —— 也就是" +"差異的報告。diff 可以以多種格式產生,包括 HTML,以及 :manpage:`diff " +"` 和 :manpage:`git diff ` 這類工具所產生的 context " +"diff 與 unified diff 格式。" #: ../../library/difflib.rst:28 msgid "" @@ -42,10 +47,13 @@ msgid "" "any type, not just text, so long as the sequence elements are :term:" "`hashable`." msgstr "" +"比較是使用實作於 :class:`SequenceMatcher` 中的匹配演算法來完成的——這是一個靈" +"活的類別,可用於比較任何型別的序列,而不僅限於文字,只要序列中的元素是\\ :" +"term:`可雜湊 `\\ 即可。" #: ../../library/difflib.rst:37 msgid "Junk heuristic" -msgstr "" +msgstr "雜訊啟發式" #: ../../library/difflib.rst:39 msgid "" @@ -53,6 +61,9 @@ msgid "" "dfn:`junk`, and ignored when searching for similarities. Ideally, these are " "uninteresting or common items, such as blank lines or whitespace." msgstr "" +":mod:`!difflib` 使用\\ :dfn:`雜訊`\\ 啟發式:某些項目會被判定為\\ :dfn:`雜訊" +"`,並在搜尋相似之處時被忽略。理想情況下,這些是不重要或常見的項目,例如空白行" +"或空白字元。" #: ../../library/difflib.rst:44 msgid "" @@ -61,12 +72,15 @@ msgid "" "understandable for humans (typically breaking on whitespace). But it can " "also cause pathological cases:" msgstr "" +"這個啟發式方法可以加速演算法的執行(因為它減少了可能組合的數量),並且可以產" +"生對人類來說更容易理解的結果(通常會在空白字元處斷開)。但它也可能導致病態情" +"況:" #: ../../library/difflib.rst:49 msgid "" "Inappropriately chosen junk items can cause an unexpectedly **large** (but " "still correct) result." -msgstr "" +msgstr "選擇不當的雜訊項目可能導致結果出乎意料地\\ **龐大**\\ (但仍然正確)。" #: ../../library/difflib.rst:51 msgid "" @@ -74,12 +88,17 @@ msgid "" "inspected when determining what is considered junk, so comparing A to B can " "give different results than comparing B to A and reversing the result." msgstr "" +"預設的啟發式方法是\\ **不對稱**\\ 的:在判斷哪些項目算是雜訊時,只會檢查第二" +"個序列,因此將 A 與 B 比較,可能會與將 B 與 A 比較後再反轉結果得到不同的結" +"果。" #: ../../library/difflib.rst:55 msgid "" "By default, if the second input sequence is at least 200 items long, items " "that account for more than 1% it are considered *junk*." msgstr "" +"在預設情況下,如果第二個輸入序列的長度至少有 200 個項目,則佔比超過 1% 的項目" +"會被視為\\ *雜訊*\\ 。" #: ../../library/difflib.rst:58 msgid "" @@ -88,10 +107,14 @@ msgid "" "``False``) or tuning it (using the *isjunk* argument, perhaps to one of the :" "ref:`predefined functions `)." msgstr "" +"根據你的資料情況,你可能需要考慮關閉這個啟發式方法(將 :class:`~difflib." +"SequenceMatcher` 的 *autojunk* 引數設為 ``False``),或是調整它(使用 " +"*isjunk* 引數,也許可以用\\ :ref:`預先定義的函式 `\\ 之一)。" #: ../../library/difflib.rst:65 msgid "The :mod:`!difflib` algorithm" -msgstr "" +msgstr ":mod:`!difflib` 的演算法" #: ../../library/difflib.rst:67 msgid "" @@ -102,18 +125,26 @@ msgid "" "recursively handle the pieces of the sequences to the left and to the right " "of the matching subsequence." msgstr "" +":class:`SequenceMatcher` 中使用的演算法比 Ratcliff 和 Obershelp 在 1980 年代" +"末以「格式塔模式匹配 (gestalt pattern matching)」這個誇張名稱發表的演算法要更" +"早出現,且稍微精巧一些。其想法是找出兩個輸入中最長的共同連續子序列,然後遞迴" +"地處理該匹配子序列左右兩側的部分。" #: ../../library/difflib.rst:76 msgid "" "`Pattern Matching: The Gestalt Approach `_" msgstr "" +"`Pattern Matching: The Gestalt Approach `_" #: ../../library/difflib.rst:77 msgid "" "Discussion of a similar algorithm by John W. Ratcliff and D. E. Metzener. " "This was published in Dr. Dobb's Journal in July, 1988." msgstr "" +"由 John W. Ratcliff 和 D. E. Metzener 討論一個類似的演算法。此文章發表於 " +"1988 年 7 月的 Dr. Dobb's Journal。" #: ../../library/difflib.rst:80 msgid "" @@ -121,10 +152,12 @@ msgid "" "searches for the longest *junk-free* contiguous subsequence. See the :ref:" "`difflib-junk` section for details." msgstr "" +"作為 Ratcliff 和 Obershelp 演算法的延伸,:mod:`!difflib` 會搜尋最長的\\ *無雜" +"訊*\\ 連續子序列。詳情請參閱\\ :ref:`difflib-junk`\\ 一節。" #: ../../library/difflib.rst:84 msgid "Timing" -msgstr "" +msgstr "耗時" #: ../../library/difflib.rst:86 msgid "" @@ -134,10 +167,13 @@ msgid "" "complicated way on how many elements the sequences have in common; best case " "time is linear." msgstr "" +"基本的 Ratcliff-Obershelp 演算法在最差情況下為三次方時間,在預期情況下為二次" +"方時間。:mod:`difflib` 的演算法在最差情況下為二次方時間,其預期情況下的行為則" +"以複雜的方式取決於這些序列共有多少元素;最佳情況下的時間則為線性。" #: ../../library/difflib.rst:97 msgid "Diff generation" -msgstr "" +msgstr "產生 diff" #: ../../library/difflib.rst:103 msgid "" @@ -208,6 +244,10 @@ msgid "" "matches preserves some notion of locality, at the occasional cost of " "producing a longer diff." msgstr "" +"請注意,由 :class:`Differ`\\ 產生的差異並不宣稱是\\ **最小**\\ 差異。相反地," +"最小差異對人類來說往往違反直覺,因為它們會盡可能地同步,有時甚至會在相隔 100 " +"頁之遠的地方進行偶然的匹配。將同步點限制在連續的匹配上,能保留某種局部性的概" +"念,但偶爾會以產生較長的差異作為代價。" #: ../../library/difflib.rst:133 msgid "The :class:`Differ` class has this constructor:" @@ -259,6 +299,9 @@ msgid "" "of newline-terminated strings, ready to be printed as-is via the :meth:`~io." "IOBase.writelines` method of a file-like object." msgstr "" +"每個序列都必須包含以換行符號結尾的個別單行字串。這樣的序列可以透過類檔案物件" +"的 :meth:`~io.IOBase.readlines` 方法取得。產生出的差異同樣由以換行符號結尾的" +"字串組成,可直接透過類檔案物件的 :meth:`~io.IOBase.writelines` 方法印出。" #: ../../library/difflib.rst:170 msgid "" @@ -273,6 +316,7 @@ msgid "" "The trailing newlines get stripped before the diff, so the result can be " "incomplete. See :gh:`71896` for details." msgstr "" +"結尾的換行符號在比對前會被去除,因此結果可能不完整。詳情請參閱 :gh:`71896`。" #: ../../library/difflib.rst:180 msgid "The constructor for this class is:" @@ -521,7 +565,7 @@ msgstr "" #: ../../library/difflib.rst:430 msgid "Junk definition functions" -msgstr "" +msgstr "雜訊定義函式" #: ../../library/difflib.rst:434 msgid "" @@ -822,9 +866,8 @@ msgid "" msgstr "" #: ../../library/difflib.rst:662 -#, fuzzy msgid "Examples" -msgstr "範例:" +msgstr "範例" #: ../../library/difflib.rst:667 msgid "SequenceMatcher examples" diff --git a/library/dis.po b/library/dis.po index 98af4b883a..5d22506a22 100644 --- a/library/dis.po +++ b/library/dis.po @@ -1593,6 +1593,9 @@ msgid "" "iterator below it). If the iterator indicates it is :term:`exhausted` then " "the byte code counter is incremented by *delta*." msgstr "" +"``STACK[-1]`` 是一個 :term:`iterator`。呼叫其 :meth:`~iterator.__next__` " +"method。如果此舉產生了一個新值,則將其推入堆疊(讓該疊代器留在它下方)。如果" +"該疊代器表示它已\\ :term:`耗盡 `,則位元組碼計數器將增加 *delta*。" #: ../../library/dis.rst:1430 msgid "Up until 3.11 the iterator was popped when it was exhausted." diff --git a/library/email.compat32-message.po b/library/email.compat32-message.po index d1e0ba6af8..11633814e8 100644 --- a/library/email.compat32-message.po +++ b/library/email.compat32-message.po @@ -150,6 +150,9 @@ msgid "" "character\" code points. (See also :meth:`.as_bytes` and :class:`~email." "generator.BytesGenerator`.)" msgstr "" +"如果訊息物件包含未依照 RFC 標準編碼的二進位資料,不合規的資料將被替換為 " +"Unicode「未知字元」碼位。(另請參閱 :meth:`.as_bytes` 和 :class:`~email." +"generator.BytesGenerator`。)" #: ../../library/email.compat32-message.rst:103 msgid "the *policy* keyword argument was added." diff --git a/library/email.contentmanager.po b/library/email.contentmanager.po index 4d551feb51..6e08ec165b 100644 --- a/library/email.contentmanager.po +++ b/library/email.contentmanager.po @@ -156,6 +156,12 @@ msgid "" "and it enables the use of the various ``add_`` methods, thereby simplifying " "the creation of multipart messages." msgstr "" +"這個內容管理器在 :class:`~email.message.Message` 本身所提供的功能之上,只額外" +"提供了最基本的介面:它只處理文字、原始位元組,以及 :class:`~email.message." +"Message` 物件。儘管如此,相較於基礎 API,它仍具有顯著的優勢:文字部分的 " +"``get_content`` 會直接回傳字串,應用程式不需要手動解碼;``set_content`` 提供" +"了豐富的選項,可用來控制加入到某部分的標頭並控制內容傳輸編碼;且它讓各種 " +"``add_`` 方法得以使用,進而簡化了多部分郵件的建立。" #: ../../library/email.contentmanager.rst:112 msgid "" @@ -166,6 +172,11 @@ msgid "" "*errors* is specified, use it as the error handler when decoding the payload " "to a string. The default error handler is ``replace``." msgstr "" +"以字串(用於 ``text`` 部分)、:class:`~email.message.EmailMessage` 物件(用" +"於 ``message/rfc822`` 部分),或 ``bytes`` 物件(用於所有其他非 multipart 型" +"別)的形式回傳該部分的 payload。若在 ``multipart`` 上呼叫,則會引發 :exc:" +"`KeyError`。如果該部分是 ``text`` 部分且指定了 *errors*,則在將 payload 解碼" +"為字串時,將其用作錯誤處理器。預設的錯誤處理器為 ``replace``。" #: ../../library/email.contentmanager.rst:131 msgid "Add headers and payload to *msg*:" diff --git a/library/email.examples.po b/library/email.examples.po index 39eb1bb2aa..1a5aa96d17 100644 --- a/library/email.examples.po +++ b/library/email.examples.po @@ -29,6 +29,8 @@ msgid "" "First, let's see how to create and send a simple text message (both the text " "content and the addresses may contain Unicode characters):" msgstr "" +"首先,讓我們來看看如何建立並傳送一封簡單的文字郵件(文字內容和位址皆可能包含 " +"Unicode 字元):" #: ../../library/email.examples.rst:12 msgid "" diff --git a/library/email.header.po b/library/email.header.po index 9179570471..c29f9116c1 100644 --- a/library/email.header.po +++ b/library/email.header.po @@ -99,6 +99,11 @@ msgid "" "`Subject` field was properly :rfc:`2047` encoded. MIME-aware mail readers " "would show this header using the embedded ISO-8859-1 character." msgstr "" +"請注意,我們是如何讓 :mailheader:`Subject` 欄位包含非 ASCII 字元的?我們透過" +"建立一個 :class:`Header` 實例,並傳入編碼時要使用的字元集來達成這一點。當隨後" +"的 :class:`~email.message.Message` 實例被扁平化時,:mailheader:`Subject` 欄位" +"會被正確地依照 :rfc:`2047` 進行編碼。支援 MIME 的郵件閱讀器會使用內嵌的 " +"ISO-8859-1 字元來顯示這個標頭。" #: ../../library/email.header.rst:57 msgid "Here is the :class:`Header` class description:" @@ -244,6 +249,9 @@ msgid "" "``'unknown-8bit'`` are decoded as ASCII using the ``'replace'`` error " "handler." msgstr "" +"以字串形式回傳 :class:`Header` 的近似表示,使用不受限制的行長度。所有片段都會" +"使用指定的編碼進行解碼,並適當地連接在一起。任何字元集為 ``'unknown-8bit'`` " +"的片段,都會使用 ``'replace'`` 錯誤處理器解碼為 ASCII。" #: ../../library/email.header.rst:158 msgid "Added handling for the ``'unknown-8bit'`` charset." diff --git a/library/email.headerregistry.po b/library/email.headerregistry.po index 85412a4785..f89cefa3a0 100644 --- a/library/email.headerregistry.po +++ b/library/email.headerregistry.po @@ -69,6 +69,8 @@ msgid "" "policy.EmailPolicy.header_factory` call. The string value of any header " "object is the *value* fully decoded to a string." msgstr "" +"*name* 和 *value* 會從 :attr:`~email.policy.EmailPolicy.header_factory` 呼叫" +"傳遞給 ``BaseHeader``。任何標頭物件的字串值,皆為完全解碼為字串後的 *value*。" #: ../../library/email.headerregistry.rst:48 msgid "This base class defines the following read-only properties:" @@ -140,6 +142,13 @@ msgid "" "handle all valid Unicode characters as well so that it can parse un-encoded " "header values." msgstr "" +"``kwds`` 是一個字典,包含一個預先初始化的鍵 ``defects``。``defects`` 是一個空" +"串列。parse 方法應該將任何偵測到的缺陷附加到此串列中。回傳時,``kwds`` 字典 *" +"必須* 至少包含 ``decoded``、``defects`` 和 ``parse_tree`` 這幾個鍵的值。" +"``decoded`` 應該是該標頭的字串值(也就是完全解碼為字串的標頭值)。" +"``parse_tree`` 會被設定為解析該標頭所得到的剖析樹。parse 方法應該假設 " +"*string* 可能包含以內容傳輸編碼(content-transfer-encoded)的部分,但也應該正" +"確處理所有有效的 Unicode 字元,以便能夠解析未編碼的標頭值。" #: ../../library/email.headerregistry.rst:106 msgid "" @@ -186,6 +195,13 @@ msgid "" "words. Defects are registered in such cases, as well as defects for issues " "such as invalid characters within the encoded words or the non-encoded text." msgstr "" +"在 :rfc:`5322` 中,非結構化(unstructured)標頭是由 ASCII 字元集中任意文字組" +"成的一段內容。然而,:rfc:`2047` 提供了一個與 :rfc:`5322` 相容的機制,可以將標" +"頭值中的非 ASCII 文字編碼為 ASCII 字元。當傳遞給建構函式的 *value* 包含編碼字" +"(encoded word)時,``UnstructuredHeader`` 剖析器會依照 :rfc:`2047` 中針對非" +"結構化文字的規則,將這些編碼字轉換為字串。該剖析器會使用啟發式方法來嘗試解碼" +"某些不符合規範的編碼字。在這種情況下會登錄缺陷(defect),對於編碼字或未編碼" +"文字中含有無效字元等問題,同樣也會登錄缺陷。" #: ../../library/email.headerregistry.rst:137 msgid "This header type provides no additional attributes." @@ -285,6 +301,10 @@ msgid "" "string. The ``decoded`` value is set by :ref:`joining ` the :" "class:`str` value of the elements of the ``groups`` attribute with ``', '``." msgstr "" +"該標頭的 ``decoded`` 值會將所有編碼字都解碼為字串。以 :class:`~encodings." +"idna` 編碼的網域名稱也會被解碼為字串。``decoded`` 值是藉由將 ``groups`` 屬性" +"中各元素的 :class:`str` 值以 ``', '``\\ :ref:`連接 ` 而設定" +"的。" #: ../../library/email.headerregistry.rst:214 msgid "" @@ -597,6 +617,11 @@ msgid "" "will be property encoded when serialized. However, per the RFCs, Unicode is " "*not* allowed in the username portion of the address." msgstr "" +"為求方便,可以指定 *addr_spec* 來取代 *username* 和 *domain*,在這種情況下," +"*username* 和 *domain* 將會從 *addr_spec* 中解析出來。*addr_spec* 必須是一個" +"正確使用 RFC 引號格式的字串;如果不是,``Address`` 將會引發錯誤。允許使用 " +"Unicode 字元,並且在序列化時會被正確編碼。然而,根據這些 RFC,位址的使用者名" +"稱部分*不*允許使用 Unicode。" #: ../../library/email.headerregistry.rst:399 msgid "" diff --git a/library/email.po b/library/email.po index 4cb84708a0..d550cb660b 100644 --- a/library/email.po +++ b/library/email.po @@ -99,6 +99,14 @@ msgid "" "modern internet software (not just email), this will be a familiar concept " "to many programmers." msgstr "" +"email 套件會盡力向應用程式隱藏各種相關 RFC 的細節。從概念上來說,應用程式應該" +"能夠將郵件訊息視為由 Unicode 文字和二進位附件組成的結構化樹狀結構,而不必擔心" +"這些內容在序列化時是如何表示的。然而,在實務上,通常有必要了解至少一些管理 " +"MIME 訊息及其結構的規則,特別是 MIME 內容類型 (content type) 的名稱與性質,以" +"及它們如何識別 multipart 文件。在大多數情況下,只有更複雜的應用程式才需要這些" +"知識,而且即便如此,也只需要了解相關的高階結構,而不必了解這些結構的具體表示" +"方式。由於 MIME 內容類型在現代網際網路軟體中被廣泛使用(不僅限於郵件),因此" +"對許多程式設計師來說,這會是個熟悉的概念。" #: ../../library/email.rst:71 msgid "" @@ -140,6 +148,12 @@ msgid "" "relevant for applications that are still using the :mod:`~email.policy." "compat32` API for backward compatibility reasons." msgstr "" +"前述內容代表 email 套件中現代、對 Unicode 友善的 API。接下來的章節從 :class:" +"`~email.message.Message` 類別開始,涵蓋了較為傳統的 :data:`~email.policy." +"compat32` API,這種 API 更直接地處理郵件訊息表示方式的細節。:data:`~email." +"policy.compat32` API 並\\ *不會*\\ 向應用程式隱藏 RFC 的細節,但對於需要在該" +"層級運作的應用程式而言,它仍是實用的工具。對於因回溯相容性原因而仍在使用 :" +"mod:`~email.policy.compat32` API 的應用程式,本文件內容同樣適用。" #: ../../library/email.rst:100 msgid "" diff --git a/library/email.policy.po b/library/email.policy.po index 3d26b74f8b..ac9785f303 100644 --- a/library/email.policy.po +++ b/library/email.policy.po @@ -633,6 +633,10 @@ msgid "" "returned. Any surrogateescaped bytes get turned into the Unicode unknown-" "character glyph." msgstr "" +"如果該值具有 ``name`` 屬性,則會原封不動地回傳。否則,*name* 以及移除任何 CR " +"或 LF 字元後的 *value*,會被傳遞給 ``header_factory``,並回傳所產生的標頭物" +"件。任何以 surrogateescape 轉義的位元組,都會被轉換成 Unicode 的未知字元字" +"形。" #: ../../library/email.policy.rst:501 msgid "" @@ -752,6 +756,10 @@ msgid "" "using a string, and the policy will take care of converting the string into " "the correct RFC encoded form." msgstr "" +"從應用程式的角度來看,這代表透過 :class:`~email.message.EmailMessage` 取得的" +"任何標頭,都是一個具有額外屬性的標頭物件,其字串值就是該標頭完全解碼後的值。" +"同樣地,也可以使用字串為標頭指定新值,或建立新的標頭,而 policy 會負責將該字" +"串轉換成正確的 RFC 編碼形式。" #: ../../library/email.policy.rst:596 msgid "" diff --git a/library/email.utils.po b/library/email.utils.po index 578329dfb9..086d0497f0 100644 --- a/library/email.utils.po +++ b/library/email.utils.po @@ -256,6 +256,12 @@ msgid "" "use if the one in the :rfc:`2231` header is not known by Python; it defaults " "to ``'us-ascii'``." msgstr "" +"當標頭參數以 :rfc:`2231` 格式編碼時,:meth:`Message.get_param ` 可能會回傳一個包含字元集、語言和數值的 3 元組。:func:" +"`collapse_rfc2231_value` 會將其轉換為字串。可選的 *errors* 會被傳遞給 :class:" +"`str` 的 :func:`~str.encode` 方法的 *errors* 引數;其預設值為 ``'replace'``。" +"可選的 *fallback_charset* 指定當 :rfc:`2231` 標頭中的字元集不被 Python 識別時" +"要使用的字元集;其預設值為 ``'us-ascii'``。" #: ../../library/email.utils.rst:214 msgid "" diff --git a/library/enum.po b/library/enum.po index 3daebfd62c..aaf9cbace3 100644 --- a/library/enum.po +++ b/library/enum.po @@ -258,9 +258,8 @@ msgstr "" "其它列舉則預設是 1 且往後遞增。" #: ../../library/enum.rst:123 -#, fuzzy msgid ":deco:`~enum.property`" -msgstr ":func:`~enum.property`" +msgstr ":deco:`~enum.property`" #: ../../library/enum.rst:125 msgid "" @@ -272,9 +271,8 @@ msgstr "" "屬性是用這個方式來實作。" #: ../../library/enum.rst:129 -#, fuzzy msgid ":deco:`unique`" -msgstr ":func:`unique`" +msgstr ":deco:`unique`" #: ../../library/enum.rst:131 msgid "" @@ -282,9 +280,8 @@ msgid "" msgstr "Enum 類別的裝飾器,用來確保任何值只有綁定到一個名稱上。" #: ../../library/enum.rst:133 -#, fuzzy msgid ":deco:`verify`" -msgstr ":func:`verify`" +msgstr ":deco:`verify`" #: ../../library/enum.rst:135 msgid "" @@ -293,27 +290,24 @@ msgid "" msgstr "Enum 類別的裝飾器,用來檢查列舉上使用者所選的限制。" #: ../../library/enum.rst:138 -#, fuzzy msgid ":deco:`member`" -msgstr ":func:`member`" +msgstr ":deco:`member`" #: ../../library/enum.rst:140 msgid "Make ``obj`` a member. Can be used as a decorator." msgstr "讓 ``obj`` 變成成員。可以當作裝飾器使用。" #: ../../library/enum.rst:142 -#, fuzzy msgid ":deco:`nonmember`" -msgstr ":func:`nonmember`" +msgstr ":deco:`nonmember`" #: ../../library/enum.rst:144 msgid "Do not make ``obj`` a member. Can be used as a decorator." msgstr "不讓 ``obj`` 變成成員。可以當作裝飾器使用。" #: ../../library/enum.rst:146 -#, fuzzy msgid ":deco:`global_enum`" -msgstr ":func:`global_enum`" +msgstr ":deco:`global_enum`" #: ../../library/enum.rst:148 msgid "" @@ -1811,14 +1805,13 @@ msgstr "" "是不相容的型別就會失敗。" #: ../../library/enum.rst:1014 -#, fuzzy msgid "" "A decorator similar to the built-in :deco:`property`, but specifically for " "enumerations. It allows member attributes to have the same names as members " "themselves." msgstr "" -"和內建的 *property* 相似的裝飾器,但只專門針對列舉。它允許成員屬性和成員本身" -"有相同名稱。" +"和內建的 :deco:`property` 相似的裝飾器,但只專門針對列舉。它允許成員屬性和成" +"員本身有相同名稱。" #: ../../library/enum.rst:1018 msgid "" diff --git a/library/filecmp.po b/library/filecmp.po index 9c1ff38a68..d38a5a82c9 100644 --- a/library/filecmp.po +++ b/library/filecmp.po @@ -72,7 +72,7 @@ msgstr "" msgid "" "Compare the files in the two directories *a* and *b* whose names are given " "by *common*." -msgstr "" +msgstr "比較目錄 *a* 和 *b* 中,名稱由 *common* 給定的檔案。" #: ../../library/filecmp.rst:44 msgid "" diff --git a/library/fnmatch.po b/library/fnmatch.po index 1a2f5f3485..d06106a7fc 100644 --- a/library/fnmatch.po +++ b/library/fnmatch.po @@ -102,6 +102,9 @@ msgid "" "functions: :func:`fnmatch`, :func:`fnmatchcase`, :func:`.filter`, :func:`." "filterfalse`." msgstr "" +"最後,請注意下列函式使用了 *maxsize* 為 32768 的 :deco:`functools." +"lru_cache`\\ 來快取(型別化的)已編譯正規表示式樣式::func:`fnmatch`、:func:" +"`fnmatchcase`、:func:`.filter`、:func:`.filterfalse`。" #: ../../library/fnmatch.rst:61 msgid "" diff --git a/library/functions.po b/library/functions.po index 8ecb5c6075..a8a8fe3f39 100644 --- a/library/functions.po +++ b/library/functions.po @@ -442,13 +442,13 @@ msgstr "" " return True" #: ../../library/functions.rst:89 -#, fuzzy msgid "" "When awaited, return the next item from the given :term:`asynchronous " "iterator`, or *default* if given and the iterator is :term:`exhausted`." msgstr "" -"當進入 await 時,從給定的 :term:`asynchronous iterator` 中回傳下一個項目" -"(item),疊代完畢則回傳 *default* 。" +"當進入 await 時,回傳給定的 :term:`asynchronous iterator` 的下一個項目;如果" +"該疊代器已\\ :term:`耗盡 `\\ 且有提供 *default*,則回傳 " +"*default*。" #: ../../library/functions.rst:92 msgid "" @@ -1269,7 +1269,6 @@ msgstr "" "此函式會執行任意程式碼。以不受信任的使用者提供的輸入來呼叫它將導致安全漏洞。" #: ../../library/functions.rst:602 -#, fuzzy msgid "" "The *source* argument is parsed and evaluated as a Python expression " "(technically speaking, an :ref:`expression list `) using the " @@ -1287,16 +1286,17 @@ msgid "" "referenced in the scope that is calling :func:`eval` (e.g. via a :keyword:" "`nonlocal` statement)." msgstr "" -"*source* 引數會被視為一條 Python 運算式(技術上而言,是條件列表)來剖析及求" -"值,而 *globals* 和 *locals* 對映分別用作全域和區域命名空間。如果 *globals* " -"dictionary 存在但缺少 ``__builtins__`` 的鍵值,那 *source* 被剖析之前,將為該" -"鍵插入對內建 :mod:`builtins` module dictionary 的引用。覆寫 ``__builtins__`` " -"可以用來限制或更改可用的名稱,但這\\ **不是**\\ 一種安全機制:被執行的程式碼" -"仍然可以存取所有內建名稱。如果 *locals* 對映被省略,那它的預設值是 *globals* " -"dictionary。如果兩個對映都被省略,則以在 :func:`eval` 被呼叫的環境中的 " -"*globals* 和 *locals* 執行原始碼。請注意,*eval()* 在封閉 (enclosing) 環境中" -"無法存取\\ :term:`巢狀作用域 ` (non-locals),除非呼叫 :func:" -"`eval` 的作用域已經有參照它們(例如透過 :keyword:`nonlocal` 陳述式)。" +"*source* 引數會被視為一條 Python 運算式(技術上而言,是\\ :ref:`運算式串列 " +"`\\ )來剖析及求值,而 *globals* 和 *locals* 對映分別用作全域和區" +"域命名空間。如果 *globals* dictionary 存在但缺少 ``__builtins__`` 的鍵值,那" +"*source* 被剖析之前,將為該鍵插入對內建 :mod:`builtins` module dictionary 的" +"引用。覆寫 ``__builtins__`` 可以用來限制或更改可用的名稱,但這\\ **不是**\\ " +"一種安全機制:被執行的程式碼仍然可以存取所有內建名稱。如果 *locals* 對映被省" +"略,那它的預設值是 *globals* dictionary。如果兩個對映都被省略,則以在 :func:" +"`eval` 被呼叫的環境中的 *globals* 和 *locals* 執行原始碼。請注意,*eval()* 在" +"封閉 (enclosing) 環境中無法存取\\ :term:`巢狀作用域 ` (non-" +"locals),除非呼叫 :func:`eval` 的作用域已經有參照它們(例如透過:keyword:" +"`nonlocal` 陳述式)。" #: ../../library/functions.rst:620 msgid "Example:" @@ -2176,7 +2176,6 @@ msgstr "" "作用域中的行為與先前版本保持不變。" #: ../../library/functions.rst:1215 -#, fuzzy msgid "" "Return an iterator that applies *function* to every item of *iterable*, " "yielding the results. If additional *iterables* arguments are passed, " @@ -2190,9 +2189,10 @@ msgstr "" "產生一個將 *function* 應用於 *iterable* 中所有項目並 yield 回傳結果的疊代器。" "如果傳遞了額外的 *iterables* 引數,則 *function* 必須接受相同個數的引數,且 " "*function* 會平行地被應用於所有可疊代物件的項目。當有多個可疊代物件時,項目最" -"少的可疊代物件耗盡時疊代器也會結束。如果 *strict* 為 ``True`` 且其中一個可疊" -"代物件在其他可疊代物件之前耗盡,則會拋出 :exc:`ValueError`。如果函式的輸入已" -"經被編排為引數的元組,請參閱 :func:`itertools.starmap`。" +"少的可疊代物件\\ :term:`耗盡 `\\ 時疊代器也會結束。如果 *strict* " +"為 ``True`` 且其中一個可疊代物件在其他可疊代物件之前耗盡,則會拋出 :exc:" +"`ValueError`。如果函式的輸入已經被編排為引數的元組,請參閱 :func:`itertools." +"starmap`。" #: ../../library/functions.rst:1224 msgid "Added the *strict* parameter." @@ -2280,15 +2280,14 @@ msgstr "" "key=keyfunc)`` 一致。" #: ../../library/functions.rst:1299 -#, fuzzy msgid "" "Retrieve the next item from the :term:`iterator` by calling its :meth:" "`~iterator.__next__` method. If *default* is given, it is returned if the " "iterator is :term:`exhausted`, otherwise :exc:`StopIteration` is raised." msgstr "" "透過呼叫 :term:`iterator` 的 :meth:`~iterator.__next__` method 取得下一個元" -"素。如果 iterator 耗盡,則回傳給定的預設值 *default*,如果沒有預設值則引發 :" -"exc:`StopIteration`。" +"素。如果 iterator 已\\ :term:`耗盡 `,則回傳給定的預設值 " +"*default*,如果沒有預設值則引發 :exc:`StopIteration`。" #: ../../library/functions.rst:1306 msgid "" @@ -2999,7 +2998,6 @@ msgstr "" "value`` 會呼叫設定器 (setter),而 ``del c.x`` 會叫用刪除器 (deleter)。" #: ../../library/functions.rst:1679 -#, fuzzy msgid "" "If given, *doc* will be the docstring of the property attribute. Otherwise, " "the property will copy *fget*'s docstring (if it exists). This makes it " @@ -3007,7 +3005,7 @@ msgid "" "term:`decorator`::" msgstr "" "如果有給定 *doc*,它將會是 property 屬性的說明字串。否則,property 會複製 " -"*fget* 的說明字串(如果它存在的話)。這樣一來,就能夠輕鬆地使用 :func:" +"*fget* 的說明字串(如果它存在的話)。這樣一來,就能夠輕鬆地使用 :deco:" "`property` 作為\\ :term:`裝飾器 `\\ 來建立唯讀屬性: ::" #: ../../library/functions.rst:1683 @@ -3418,13 +3416,12 @@ msgstr "" "可以在類別定義中使用(例如 ``f()``)。" #: ../../library/functions.rst:1921 -#, fuzzy msgid "" "Static methods in Python are similar to those found in Java or C++. Also, " "see :deco:`classmethod` for a variant that is useful for creating alternate " "class constructors." msgstr "" -"Python 中的靜態方法類似於 Java 或 C++ 中的靜態方法。另請參閱 :func:" +"Python 中的靜態方法類似於 Java 或 C++ 中的靜態方法。另請參閱 :deco:" "`classmethod`,它是一個對於建立替代類別建構式很有用的變體。" #: ../../library/functions.rst:1925 @@ -3759,6 +3756,9 @@ msgid "" "the metaclass ``__prepare__`` method (see :ref:`prepare`). Use :func:`types." "new_class` to dynamically create a class using the appropriate metaclass." msgstr "" +"與 :keyword:`class` 陳述式不同,三引數形式不會呼叫元類別的 ``__prepare__`` 方" +"法(見 :ref:`prepare`)。請使用 :func:`types.new_class` 以適當的元類別動態建" +"立類別。" #: ../../library/functions.rst:2118 msgid "See also :ref:`class-customization`." @@ -3874,14 +3874,14 @@ msgstr "" "同的方式來處理這個問題:" #: ../../library/functions.rst:2177 -#, fuzzy msgid "" "By default, :func:`zip` stops when the shortest iterable is :term:" "`exhausted`. It will ignore the remaining items in the longer iterables, " "cutting off the result to the length of the shortest iterable::" msgstr "" -"預設情況下,:func:`zip` 會在最短的可疊代物件用盡時停止。它會忽略較長可疊代物" -"件中的剩餘項目,將結果截斷到最短可疊代物件的長度: ::" +"預設情況下,:func:`zip` 會在最短的可疊代物件\\ :term:`耗盡 `\\ 時" +"停止。它會忽略較長可疊代物件中的剩餘項目,將結果截斷到最短可疊代物件的長" +"度: ::" #: ../../library/functions.rst:2181 msgid "" @@ -3909,13 +3909,12 @@ msgstr "" "[('a', 1), ('b', 2), ('c', 3)]" #: ../../library/functions.rst:2191 -#, fuzzy msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is :term:`exhausted` before the others:" msgstr "" -"與預設行為不同的是,如果有一個可疊代物件先於其他可疊代物件耗盡,它會引發 :" -"exc:`ValueError`:" +"與預設行為不同的是,如果有一個可疊代物件先於其他可疊代物件\\ :term:`耗盡 " +"`,它會引發 :exc:`ValueError`:" #: ../../library/functions.rst:2209 msgid "" diff --git a/library/functools.po b/library/functools.po index ecafb25748..80e4e1a948 100644 --- a/library/functools.po +++ b/library/functools.po @@ -51,7 +51,6 @@ msgstr "" "Memoization>`_。" #: ../../library/functools.rst:34 -#, fuzzy msgid "" "Returns the same as ``lru_cache(maxsize=None)``, creating a thin wrapper " "around a dictionary lookup for the function arguments. Because it never " @@ -59,7 +58,7 @@ msgid "" "with a size limit." msgstr "" "和 ``lru_cache(maxsize=None)`` 回傳相同的值,為函式引數建立一個字典查找的薄包" -"裝器。因為它永遠不需要丟棄舊值,所以這比有大小限制的 :func:`lru_cache` 更小、" +"裝器。因為它永遠不需要丟棄舊值,所以這比有大小限制的 :deco:`lru_cache` 更小、" "更快。" #: ../../library/functools.rst:39 ../../library/functools.rst:297 @@ -109,7 +108,6 @@ msgstr "" "多次呼叫。" #: ../../library/functools.rst:65 -#, fuzzy msgid "" "Transform a method of a class into a property whose value is computed once " "and then cached as a normal attribute for the life of the instance. Similar " @@ -117,8 +115,9 @@ msgid "" "computed properties of instances that are otherwise effectively immutable." msgstr "" "將類別的一個方法轉換為屬性 (property),其值會計算一次,然後在實例的生命週期內" -"快取為普通屬性。類似 :func:`property`,但增加了快取機制。對於除使用該裝飾器的" -"屬性外實質上幾乎是不可變 (immutable) 的實例,針對其所需要繁重計算會很有用。" +"快取為普通屬性。類似 :deco:`property`,但增加了快取機制。對於除使用該裝飾" +"器的屬性外實質上幾乎是不可變 (immutable) 的實例,針對其所需要繁重計算會很有" +"用。" #: ../../library/functools.rst:70 ../../library/functools.rst:142 #: ../../library/functools.rst:438 @@ -146,13 +145,12 @@ msgstr "" " return statistics.stdev(self._data)" #: ../../library/functools.rst:81 -#, fuzzy msgid "" "The mechanics of :deco:`cached_property` are somewhat different from :deco:" "`property`. A regular property blocks attribute writes unless a setter is " "defined. In contrast, a *cached_property* allows writes." msgstr "" -":func:`cached_property` 的機制與 :func:`property` 有所不同。除非定義了 " +":deco:`cached_property` 的機制與 :deco:`property` 有所不同。除非定義了 " "setter,否則常規屬性會阻止屬性的寫入。相反地,*cached_property* 則允許寫入。" #: ../../library/functools.rst:85 @@ -215,7 +213,6 @@ msgstr "" "``__dict__`` 屬性)。" #: ../../library/functools.rst:113 -#, fuzzy msgid "" "If a mutable mapping is not available or if space-efficient key sharing is " "desired, an effect similar to :deco:`cached_property` can also be achieved " @@ -223,13 +220,12 @@ msgid "" "cache-method-calls` for more details on how this differs from :deco:" "`cached_property`." msgstr "" -"如果可變對映不可用或需要金鑰共享以節省空間,則也可以透過在 :func:`lru_cache` " -"之上堆疊 :func:`property` 來實作類似於 :func:`cached_property` 的效果。請參閱" -"\\ :ref:`faq-cache-method-calls`\\ 以了解有關這與 :func:`cached_property` 間" +"如果可變對映不可用或需要金鑰共享以節省空間,則也可以透過在 :deco:`lru_cache` " +"之上堆疊 :deco:`property` 來實作類似於 :deco:`cached_property` 的效果。請參閱" +"\\ :ref:`faq-cache-method-calls`\\ 以了解有關這與 :deco:`cached_property` 間" "不同之處的更多詳細資訊。" #: ../../library/functools.rst:120 -#, fuzzy msgid "" "Prior to Python 3.12, :deco:`!cached_property` included an undocumented lock " "to ensure that in multi-threaded usage the getter function was guaranteed to " @@ -237,9 +233,9 @@ msgid "" "instance, which could result in unacceptably high lock contention. In Python " "3.12+ this locking is removed." msgstr "" -"在 Python 3.12 之前,``cached_property`` 包含一個未以文件記錄的鎖,以確保在多" -"執行緒使用中能保證 getter 函式對於每個實例只會執行一次。然而,鎖是針對每個屬" -"性,而不是針對每個實例,這可能會導致無法被接受的嚴重鎖爭用 (lock " +"在 Python 3.12 之前,:deco:`!cached_property` 包含一個未以文件記錄的鎖,以確" +"保在多執行緒使用中能保證 getter 函式對於每個實例只會執行一次。然而,鎖是針對" +"每個屬性,而不是針對每個實例,這可能會導致無法被接受的嚴重鎖爭用 (lock " "contention)。在 Python 3.12+ 中,此鎖已被刪除。" #: ../../library/functools.rst:130 @@ -705,6 +701,10 @@ msgid "" "new :data:`!Placeholder` sentinel to the place held by a previous :data:`!" "Placeholder`:" msgstr "" +"如果將 :func:`!partial` 套用於現有的 :ref:`partial 物件 `,該輸入物件的 :data:`!Placeholder` 標記會被新的位置引數所填入。" +"可以透過在先前 :data:`!Placeholder` 所在的位置插入新的 :data:`!Placeholder` " +"標記,來保留該佔位符:" #: ../../library/functools.rst:398 msgid "" @@ -1369,7 +1369,6 @@ msgstr "" "裝器函式的 :attr:`~function.__dict__`,即實例字典)。" #: ../../library/functools.rst:734 -#, fuzzy msgid "" "To allow access to the original function for introspection and other " "purposes (e.g. bypassing a caching decorator such as :deco:`lru_cache`), " @@ -1377,8 +1376,8 @@ msgid "" "that refers to the function being wrapped." msgstr "" "為了允許出於內省 (introspection) 和其他目的所對原始函式的存取(例如繞過快取裝" -"飾器,如 :func:`lru_cache`),此函式會自動向包裝器新增 ``__wrapped__`` 屬性," -"該包裝器參照被包裝的函式。" +"飾器,如 :deco:`lru_cache`),此函式會自動向包裝器新增 ``__wrapped__`` 屬" +"性,該包裝器參照被包裝的函式。" #: ../../library/functools.rst:739 msgid "" diff --git a/library/getopt.po b/library/getopt.po index 6d73e6a5b7..83f540710c 100644 --- a/library/getopt.po +++ b/library/getopt.po @@ -93,7 +93,7 @@ msgstr "" #: ../../library/getopt.rst:65 msgid "" "If *longopts* is a string it gets treated as a list of a single element." -msgstr "" +msgstr "如果 *longopts* 是一個字串,它會被視為只有單一元素的串列。" #: ../../library/getopt.rst:67 msgid "" diff --git a/library/glob.po b/library/glob.po index 633d680bcb..87909d7ea9 100644 --- a/library/glob.po +++ b/library/glob.po @@ -47,16 +47,15 @@ msgid "" msgstr "路徑名稱不會以特定順序回傳。如果你需要特定的順序,請對結果進行排序。" #: ../../library/glob.rst:32 -#, fuzzy msgid "" "By default, files beginning with a dot (``.``) can only be matched by " "patterns that also start with a dot, unlike :func:`fnmatch.fnmatch` or :func:" "`pathlib.Path.glob`. For tilde and shell variable expansion, use :func:`os." "path.expanduser` and :func:`os.path.expandvars`." msgstr "" -"以點 (``.``) 開頭的檔案只能與同樣以點開頭的模式匹配,這與 :func:`fnmatch." -"fnmatch` 或 :func:`pathlib.Path.glob` 不同。對於波浪號和 shell 變數擴展,請使" -"用 :func:`os.path.expanduser` 和 :func:`os.path.expandvars`。" +"根據預設,以點 (``.``) 開頭的檔案只能與同樣以點開頭的模式匹配,這與 :func:" +"`fnmatch.fnmatch` 或 :func:`pathlib.Path.glob` 不同。對於波浪號和 shell 變數" +"擴展,請使用 :func:`os.path.expanduser` 和 :func:`os.path.expandvars`。" #: ../../library/glob.rst:38 msgid "" @@ -122,6 +121,8 @@ msgid "" "If *include_hidden* is true, wildcards can match path segments that begin " "with a dot (``.``)." msgstr "" +"如果 *include_hidden* 為真,通用字元 (wildcard) 可以匹配以點 (``.``) 開頭的路" +"徑區段。" #: ../../library/glob.rst:76 ../../library/glob.rst:108 msgid "" @@ -179,7 +180,6 @@ msgstr "" "部的值。" #: ../../library/glob.rst:132 -#, fuzzy msgid "" "Escape all special characters (``'?'``, ``'*'`` and ``'['``). This is useful " "if you want to match an arbitrary literal string that may have special " diff --git a/library/http.client.po b/library/http.client.po index 61b33b3f8f..d0e565f995 100644 --- a/library/http.client.po +++ b/library/http.client.po @@ -309,6 +309,15 @@ msgid "" "*body* is an iterable, the elements of the iterable are sent as is until the " "iterable is :term:`exhausted`." msgstr "" +"如果指定了 *body*,則在標頭 (header) 完成之後,會傳送指定的資料。它可以是 :" +"class:`str`、:term:`bytes-like object`、一個開啟的 :term:`file object`,或是" +"一個 :class:`bytes` 的可疊代物件。如果 *body* 是字串,則會以 ISO-8859-1" +"(HTTP 的預設編碼)進行編碼。如果它是一個類位元組串物件,則會按原樣傳送這些位" +"元組。如果它是一個 :term:`file object`,則會傳送該檔案的內容;此檔案物件應至" +"少支援 ``read()`` method。如果該檔案物件是 :class:`io.TextIOBase` 的實例,則 " +"``read()`` method 回傳的資料將以 ISO-8859-1 編碼;否則 ``read()`` 回傳的資料" +"將按原樣傳送。如果 *body* 是一個可疊代物件,則該可疊代物件中的元素將按原樣傳" +"送,直到該可疊代物件\\ :term:`耗盡 `\\ 為止。" #: ../../library/http.client.rst:274 msgid "" diff --git a/library/http.cookiejar.po b/library/http.cookiejar.po index f484762e60..65df5cb52a 100644 --- a/library/http.cookiejar.po +++ b/library/http.cookiejar.po @@ -59,7 +59,6 @@ msgstr "" "屬性。" #: ../../library/http.cookiejar.rst:31 -#, fuzzy msgid "" "The various named parameters found in :mailheader:`Set-Cookie` and :" "mailheader:`Set-Cookie2` headers (for example, ``domain`` and ``expires``) " @@ -147,7 +146,6 @@ msgid "" msgstr "此類別負責決定是否應從伺服器接受 / 回傳每個 cookie。" #: ../../library/http.cookiejar.rst:89 -#, fuzzy msgid "" "Constructor arguments should be passed as keyword arguments only. " "*blocked_domains* is a sequence of domain names that we never accept cookies " @@ -159,14 +157,13 @@ msgid "" "`CookiePolicy` and :class:`DefaultCookiePolicy` objects." msgstr "" "建構函式引數只能以關鍵字引數的形式傳送。*blocked_domains* 是我們從不接受 " -"cookies 或回傳 cookies 的網域名稱序列。*allowed_domains* 如果不是 :const:" -"`None`,這是我們接受並回傳 cookies 的唯一網域名稱序列。 *secure_protocols* 是" -"可以加入安全 cookies 的通訊協定序列。預設情況下,*https* 和 *wss*\\ (安全 " +"cookies 或回傳 cookies 的網域名稱序列。*allowed_domains* 如果不是 ``None``," +"這是我們接受並回傳 cookies 的唯一網域名稱序列。*secure_protocols* 是可以加入" +"安全 cookies 的通訊協定序列。預設情況下,*https* 和 *wss*\\ (安全 " "websocket)會被視為安全通訊協定。所有其他引數請參閱 :class:`CookiePolicy` " "及 :class:`DefaultCookiePolicy` 物件的說明文件。" #: ../../library/http.cookiejar.rst:98 -#, fuzzy msgid "" ":class:`DefaultCookiePolicy` implements the standard accept / reject rules " "for Netscape and :rfc:`2965` cookies. By default, :rfc:`2109` cookies (that " @@ -180,23 +177,22 @@ msgid "" msgstr "" ":class:`DefaultCookiePolicy` 實作了 Netscape 和 :rfc:`2965` cookies 的標準接" "受/拒絕規則。預設情況下,:rfc:`2109` cookies(即在 :mailheader:`Set-Cookie` " -"標頭中接收到的版本 cookie-attribute 為 1 的 cookies)會根據 RFC 2965 規則處" -"理。 但是,如果 RFC 2965 處理被關閉,或者 :attr:`rfc2109_as_netscape` 是 " -"``True``,RFC 2109 cookie 會被 :class:`CookieJar` 實例「降級 」為 Netscape " -"cookie,方法是將 :class:`Cookie` 實例的 :attr:`version` 屬性設為 0。:class:" -"`DefaultCookiePolicy` 也提供了一些參數來允許對策略進行一些微調。" +"標頭中收到的、版本 cookie 屬性為 1 的 cookies)會依 RFC 2965 規則處理。但是," +"如果 RFC 2965 處理被關閉,或 :attr:`rfc2109_as_netscape` 為 ``True``,RFC " +"2109 cookies 會被 :class:`CookieJar` 實例「降級」為 Netscape cookies,方法是" +"將 :class:`Cookie` 實例的 :attr:`~Cookie.version` 屬性設為 0。:class:" +"`DefaultCookiePolicy` 也提供了一些參數,可對策略進行微調。" #: ../../library/http.cookiejar.rst:111 -#, fuzzy msgid "" "This class represents Netscape, :rfc:`2109` and :rfc:`2965` cookies. It is " "not expected that users of :mod:`!http.cookiejar` construct their own :class:" "`Cookie` instances. Instead, if necessary, call :meth:`~CookieJar." "make_cookies` on a :class:`CookieJar` instance." msgstr "" -"這個類別代表 Netscape、:rfc:`2109` 和 :rfc:`2965` cookies。 我們不希望 :mod:" -"`!http.cookiejar` 的使用者建立自己的 :class:`Cookie` 實例。 如有必要,請在 :" -"class:`CookieJar` 實例上呼叫 :meth:`make_cookies`。" +"這個類別代表 Netscape、:rfc:`2109` 和 :rfc:`2965` cookies。我們不希望 :mod:`!" +"http.cookiejar` 的使用者建立自己的 :class:`Cookie` 實例。如有必要,請在 :" +"class:`CookieJar` 實例上呼叫 :meth:`~CookieJar.make_cookies`。" #: ../../library/http.cookiejar.rst:119 msgid "Module :mod:`urllib.request`" @@ -267,7 +263,6 @@ msgid ":rfc:`2964` - Use of HTTP State Management" msgstr ":rfc:`2964` - HTTP 狀態管理使用方法" #: ../../library/http.cookiejar.rst:148 -#, fuzzy msgid "CookieJar and FileCookieJar objects" msgstr "CookieJar 與 FileCookieJar 物件" @@ -288,7 +283,6 @@ msgid "Add correct :mailheader:`Cookie` header to *request*." msgstr "將正確的 :mailheader:`Cookie` 標頭加入 *request*。" #: ../../library/http.cookiejar.rst:160 -#, fuzzy msgid "" "If policy allows (that is, the :attr:`~CookiePolicy.rfc2965` and :attr:" "`~CookiePolicy.hide_cookie2` attributes of the :class:`CookieJar`'s :class:" @@ -296,11 +290,10 @@ msgid "" "`Cookie2` header is also added when appropriate." msgstr "" "如果策略允許(即 :class:`CookieJar` 的 :class:`CookiePolicy` 實例的 :attr:" -"`rfc2965` 和 :attr:`hide_cookie2` 屬性分別為 true 和 false),:mailheader:" -"`Cookie2` 標頭也會在適當的時候加入。" +"`~CookiePolicy.rfc2965` 和 :attr:`~CookiePolicy.hide_cookie2` 屬性分別為 " +"true 和 false),:mailheader:`Cookie2` 標頭也會在適當的時候加入。" #: ../../library/http.cookiejar.rst:165 -#, fuzzy msgid "" "The *request* object (usually a :class:`urllib.request.Request` instance) " "must support the methods :meth:`~urllib.request.Request.get_full_url`, :meth:" @@ -312,20 +305,22 @@ msgid "" "origin_req_host` as documented by :mod:`urllib.request`." msgstr "" "如 :mod:`urllib.request` 文件所述,*request* 物件(通常是 :class:`urllib." -"request.Request` 的實例)必須支援 :meth:`get_full_url`、:meth:`has_header`、:" -"meth:`get_header`、:meth:`header_items`、:meth:`add_unredirected_header` 方法" -"與 :attr:`host`、:attr:`!type`、:attr:`unverifiable`、:attr:" -"`origin_req_host` 屬性。" +"request.Request` 的實例)必須支援 :meth:`~urllib.request.Request." +"get_full_url`、:meth:`~urllib.request.Request.has_header`、:meth:`~urllib." +"request.Request.get_header`、:meth:`~urllib.request.Request.header_items`、:" +"meth:`~urllib.request.Request.add_unredirected_header` 方法,以及 :attr:" +"`~urllib.request.Request.host`、:attr:`~urllib.request.Request.type`、:attr:" +"`~urllib.request.Request.unverifiable`、:attr:`~urllib.request.Request." +"origin_req_host` 屬性。" #: ../../library/http.cookiejar.rst:178 ../../library/http.cookiejar.rst:208 -#, fuzzy msgid "" "*request* object needs :attr:`~urllib.request.Request.origin_req_host` " "attribute. Dependency on a deprecated method :meth:`!get_origin_req_host` " "has been removed." msgstr "" -"*request* 物件需要 :attr:`origin_req_host` 屬性。已移除對已廢棄方法 :meth:" -"`get_origin_req_host` 的依賴。" +"*request* 物件需要 :attr:`~urllib.request.Request.origin_req_host` 屬性。已移" +"除對已棄用方法 :meth:`!get_origin_req_host` 的依賴。" #: ../../library/http.cookiejar.rst:185 msgid "" @@ -347,18 +342,16 @@ msgstr "" "`CookiePolicy.set_ok` 方法的檢測)。" #: ../../library/http.cookiejar.rst:192 -#, fuzzy msgid "" "The *response* object (usually the result of a call to :meth:`urllib.request." "urlopen`, or similar) should support an :meth:`~http.client.HTTPResponse." "info` method, which returns an :class:`email.message.Message` instance." msgstr "" "*response* 物件(通常是呼叫 :meth:`urllib.request.urlopen` 的結果或類似的東" -"西)應該支援 :meth:`info` 方法,它會回傳一個 :class:`email.message.Message` " -"的實例。" +"西)應該支援 :meth:`~http.client.HTTPResponse.info` 方法,它會回傳一個 :" +"class:`email.message.Message` 的實例。" #: ../../library/http.cookiejar.rst:197 -#, fuzzy msgid "" "The *request* object (usually a :class:`urllib.request.Request` instance) " "must support the method :meth:`~urllib.request.Request.get_full_url` and the " @@ -368,10 +361,12 @@ msgid "" "values for cookie-attributes as well as for checking that the cookie is " "allowed to be set." msgstr "" -"如 :mod:`urllib.request` 的檔案所說,*request* 物件(通常是 :class:`urllib." -"request.Request` 的實例)必須支援 :meth:`get_full_url` 方法以及 :attr:" -"`host`、:attr:`unverifiable` 和 :attr:`origin_req_host` 等屬性,該請求被用於" -"設置 cookie-attributes 的預設值並檢查 cookie 是否允許被設置。" +"如 :mod:`urllib.request` 的文件所述,*request* 物件(通常是 :class:`urllib." +"request.Request` 的實例)必須支援 :meth:`~urllib.request.Request." +"get_full_url` 方法,以及 :attr:`~urllib.request.Request.host`、:attr:" +"`~urllib.request.Request.unverifiable` 和 :attr:`~urllib.request.Request." +"origin_req_host` 等屬性,該請求被用於設定 cookie 屬性的預設值,並檢查 cookie " +"是否允許被設定。" #: ../../library/http.cookiejar.rst:214 msgid "Set the :class:`CookiePolicy` instance to be used." @@ -426,7 +421,6 @@ msgid "Discard all session cookies." msgstr "刪除所有 session cookies。" #: ../../library/http.cookiejar.rst:253 -#, fuzzy msgid "" "Discards all contained cookies that have a true :attr:`~Cookie.discard` " "attribute (usually because they had either no ``max-age`` or ``expires`` " @@ -434,18 +428,17 @@ msgid "" "interactive browsers, the end of a session usually corresponds to closing " "the browser window." msgstr "" -"刪除所有包含有 true :attr:`discard` 屬性的 cookie (通常是因為它們沒有 `max-" -"age` 或 `expires` cookie 屬性,或有明確的 `discard` cookie 屬性)。 對於互動式" -"瀏覽器,工作階段的結束通常對應於關閉瀏覽器視窗。" +"刪除所有帶有 true :attr:`~Cookie.discard` 屬性的 cookie(通常是因為它們沒有 " +"``max-age`` 或 ``expires`` cookie 屬性,或有明確的 ``discard`` cookie 屬" +"性)。對於互動式瀏覽器,工作階段的結束通常對應於關閉瀏覽器視窗。" #: ../../library/http.cookiejar.rst:258 -#, fuzzy msgid "" "Note that the :meth:`~FileCookieJar.save` method won't save session cookies " "anyway, unless you ask otherwise by passing a true *ignore_discard* argument." msgstr "" -"請注意 :meth:`save` 方法無論如何都不會儲存 session cookies,除非你透過傳入 " -"true *ignore_discard* 引數來要求。" +"請注意,:meth:`~FileCookieJar.save` 方法無論如何都不會儲存 session cookies," +"除非你透過傳入值為 true 的 *ignore_discard* 引數來要求。" #: ../../library/http.cookiejar.rst:261 msgid ":class:`FileCookieJar` implements the following additional methods:" @@ -463,16 +456,16 @@ msgstr "" "這個基底類別會產生 :exc:`NotImplementedError`。子類別可以不實作此方法。" #: ../../library/http.cookiejar.rst:271 -#, fuzzy msgid "" "*filename* is the name of file in which to save cookies. If *filename* is " "not specified, :attr:`self.filename ` is used (whose " "default is the value passed to the constructor, if any); if :attr:`self." "filename ` is ``None``, :exc:`ValueError` is raised." msgstr "" -"*filename* 是儲存 cookies 的檔案名稱。 如果 *filename* 未指定,則會使用 :" -"attr:`self.filename` (其預設值是傳給建構函式的值(如果有));如果 :attr:" -"`self.filename` 是 :const:`None`,則會產生 :exc:`ValueError`。" +"*filename* 是用來儲存 cookies 的檔案名稱。如果未指定 *filename*,則會使用 :" +"attr:`self.filename `\\ (其預設值為傳給建構函式的" +"值,如果有的話);如果 :attr:`self.filename ` 為 " +"``None``,則會引發 :exc:`ValueError`。" #: ../../library/http.cookiejar.rst:277 msgid "" @@ -605,7 +598,6 @@ msgstr "" "案中,這是很方便的。" #: ../../library/http.cookiejar.rst:368 -#, fuzzy msgid "CookiePolicy objects" msgstr "CookiePolicy 物件" @@ -738,7 +730,6 @@ msgstr "" "略',允許設定和接收任何和所有的 cookies (這不太可能有用)。" #: ../../library/http.cookiejar.rst:452 -#, fuzzy msgid "DefaultCookiePolicy objects" msgstr "DefaultCookiePolicy 物件" @@ -796,7 +787,6 @@ msgstr "" "的 Netscape 通訊協定(代價是阻擋一些良性 cookies)。" #: ../../library/http.cookiejar.rst:478 -#, fuzzy msgid "" "A domain blocklist and allowlist is provided (both off by default). Only " "domains not in the blocklist and present in the allowlist (if the allowlist " @@ -806,11 +796,12 @@ msgid "" "methods (and the corresponding argument and methods for *allowed_domains*). " "If you set an allowlist, you can turn it off again by setting it to ``None``." msgstr "" -"提供網域阻止清單和允許清單(預設都關閉)。只有不在阻止清單中和在允許清單中" -"(如果允許清單是有效的)的網域才參與 cookie 設定和回傳。使用 " -"*blocked_domains* 構造函式引數,以及 :meth:`blocked_domains` 和 :meth:" -"`set_blocked_domains` 方法(以及 *allowed_domains* 的相應引數和方法)。如果你" -"設定了允許清單,你可以透過設定為 :const:`None` 來再次關閉它。" +"提供了網域阻止清單和允許清單(預設都關閉)。只有不在阻止清單中,且在允許清單" +"中(如果允許清單為有效狀態)的網域,才會參與 cookie 的設定和回傳。使用 " +"*blocked_domains* 建構函式引數,以及 :meth:`~DefaultCookiePolicy." +"blocked_domains` 和 :meth:`~DefaultCookiePolicy.set_blocked_domains` 方法(以" +"及 *allowed_domains* 的相應引數和方法)。如果你設定了允許清單,可以透過將它設" +"為 ``None`` 來再次關閉它。" #: ../../library/http.cookiejar.rst:486 msgid "" @@ -852,14 +843,12 @@ msgid "" msgstr "如果 *domain* 在設定或接收 cookies 的阻止列表上,則回傳 ``True``。" #: ../../library/http.cookiejar.rst:516 -#, fuzzy msgid "Return ``None``, or the sequence of allowed domains (as a tuple)." -msgstr "回傳 :const:`None`,或允許網域的序列(以元組形式)。" +msgstr "回傳 ``None``,或允許網域的序列(以元組形式)。" #: ../../library/http.cookiejar.rst:521 -#, fuzzy msgid "Set the sequence of allowed domains, or ``None``." -msgstr "設定允許網域的序列,或 :const:`None`。" +msgstr "設定允許網域的序列,或 ``None``。" #: ../../library/http.cookiejar.rst:526 msgid "" @@ -877,7 +866,6 @@ msgstr "" "初始化,而且都可以被指定。" #: ../../library/http.cookiejar.rst:536 -#, fuzzy msgid "" "If true, request that the :class:`CookieJar` instance downgrade :rfc:`2109` " "cookies (that is, cookies received in a :mailheader:`Set-Cookie` header with " @@ -888,10 +876,10 @@ msgid "" "by default." msgstr "" "如果為 true,請求 :class:`CookieJar` 實例透過設定 :class:`Cookie` 實例的版本" -"屬性為 0,將 :rfc:`2109` cookies (即在 :mailheader:`Set-Cookie` 標頭中收到" -"的、版本 cookie 屬性為 1 的 cookies) 降級為 Netscape cookies。 預設值是 :" -"const:`None`,在這種情況下,如果且僅如果 :rfc:`2965` 處理被關閉,RFC 2109 " -"cookies 才會被降級。 因此,RFC 2109 cookie 在預設情況下被降級。" +"屬性為 0,將 :rfc:`2109` cookies(即在 :mailheader:`Set-Cookie` 標頭中收到" +"的、版本 cookie 屬性為 1 的 cookies)降級為 Netscape cookies。預設值是 " +"``None``,在這種情況下,如果且僅如果 :rfc:`2965` 處理被關閉,RFC 2109 " +"cookies 才會被降級。因此,RFC 2109 cookies 在預設情況下會被降級。" #: ../../library/http.cookiejar.rst:544 msgid "General strictness switches:" @@ -957,7 +945,6 @@ msgstr "" "被設定)。" #: ../../library/http.cookiejar.rst:592 -#, fuzzy msgid "" "When setting cookies, the 'host prefix' must not contain a dot (for example, " "``www.foo.bar.com`` can't set a cookie for ``.bar.com``, because ``www.foo`` " @@ -967,16 +954,15 @@ msgstr "" "bar.com`` 設定 cookie,因為 ``www.foo`` 包含一個點)。" #: ../../library/http.cookiejar.rst:599 -#, fuzzy msgid "" "Cookies that did not explicitly specify a ``domain`` cookie-attribute can " "only be returned to a domain equal to the domain that set the cookie (for " "example, ``spam.example.com`` won't be returned cookies from ``example.com`` " "that had no ``domain`` cookie-attribute)." msgstr "" -"未明確指定 ``domain`` cookie-attribute 的 Cookie 只能回傳給與設定 Cookie 的網" -"域相同的網域(例如,``spam.example.com`` 將不會回傳來自 ``example.com`` 但沒" -"有 ``domain`` cookie-attribute 的 Cookie)。" +"未明確指定 ``domain`` cookie 屬性的 cookie 只能回傳給與設定該 cookie 相同的網" +"域(例如,``spam.example.com`` 不會收到來自 ``example.com`` 且未指定 " +"``domain`` cookie 屬性的 cookie)。" #: ../../library/http.cookiejar.rst:607 msgid "When setting cookies, require a full :rfc:`2965` domain-match." @@ -989,7 +975,6 @@ msgid "" msgstr "為了方便起見,以下屬性是上述旗標最有用的組合:" #: ../../library/http.cookiejar.rst:615 -#, fuzzy msgid "" "Equivalent to 0 (that is, all of the above Netscape domain strictness flags " "switched off)." @@ -1000,7 +985,6 @@ msgid "Equivalent to ``DomainStrictNoDots|DomainStrictNonDomain``." msgstr "等價於 ``DomainStrictNoDots|DomainStrictNonDomain``。" #: ../../library/http.cookiejar.rst:625 -#, fuzzy msgid "Cookie objects" msgstr "Cookie 物件" @@ -1030,42 +1014,37 @@ msgstr "" "這個類別不會強制執行內部一致性,所以如果你這麼做,你應該要知道你在做什麼。" #: ../../library/http.cookiejar.rst:642 -#, fuzzy msgid "" "Integer or ``None``. Netscape cookies have :attr:`version` 0. :rfc:`2965` " "and :rfc:`2109` cookies have a ``version`` cookie-attribute of 1. However, " "note that :mod:`!http.cookiejar` may 'downgrade' RFC 2109 cookies to " "Netscape cookies, in which case :attr:`version` is 0." msgstr "" -"整數或 :const:`None`。 Netscape cookie 的 :attr:`version` 為 0。 :rfc:`2965` " -"和 :rfc:`2109` cookie 的 ``version`` cookie 屬性為 1。但是,請注意 :mod:`!" -"http.cookiejar` 可能會將 RFC 2109 cookie 「降級」 為 Netscape cookie,在這種" -"情況下 :attr:`version` 為 0。" +"整數或 ``None``。Netscape cookies 的 :attr:`version` 為 0。:rfc:`2965` 和 :" +"rfc:`2109` cookies 的 ``version`` cookie 屬性為 1。但請注意,:mod:`!http." +"cookiejar` 可能會將 RFC 2109 cookies「降級」為 Netscape cookies,在這種情況" +"下 :attr:`version` 為 0。" #: ../../library/http.cookiejar.rst:650 msgid "Cookie name (a string)." msgstr "Cookie 名稱(字串)。" #: ../../library/http.cookiejar.rst:655 -#, fuzzy msgid "Cookie value (a string), or ``None``." -msgstr "Cookie 值(字串),或 :const:`None`。" +msgstr "Cookie 值(字串),或 ``None``。" #: ../../library/http.cookiejar.rst:660 -#, fuzzy msgid "" "String representing a port or a set of ports (for example, '80', or " "'80,8080'), or ``None``." msgstr "" -"代表一個連接埠或一組連接埠的字串 (例如「80」,或「880,8080」),或 :const:" -"`None`。" +"代表一個連接埠或一組連接埠的字串(例如「80」,或「80,8080」),或 ``None``。" #: ../../library/http.cookiejar.rst:666 msgid "Cookie domain (a string)." msgstr "Cookie 網域(字串)。" #: ../../library/http.cookiejar.rst:671 -#, fuzzy msgid "Cookie path (a string, for example, ``'/acme/rocket_launchers'``)." msgstr "Cookie 路徑(字串,例如 ``'/acme/rocket_launchers'``)。" @@ -1074,12 +1053,11 @@ msgid "``True`` if cookie should only be returned over a secure connection." msgstr "如果 cookie 只能透過安全連線回傳,則為 ``True``。" #: ../../library/http.cookiejar.rst:681 -#, fuzzy msgid "" "Integer expiry date in seconds since epoch, or ``None``. See also the :meth:" "`is_expired` method." msgstr "" -"自 epoch 起計算的整數到期時間,以秒為單位,或 :const:`None`。另請參閱 :meth:" +"自 epoch 起計算的整數到期時間,以秒為單位,或 ``None``。另請參閱 :meth:" "`is_expired` 方法。" #: ../../library/http.cookiejar.rst:687 @@ -1087,22 +1065,18 @@ msgid "``True`` if this is a session cookie." msgstr "如果這是 session cookie,即為 ``True``。" #: ../../library/http.cookiejar.rst:692 -#, fuzzy msgid "" "String comment from the server explaining the function of this cookie, or " "``None``." -msgstr "來自伺服器解釋此 cookie 功能的字串註解,或 :const:`None`。" +msgstr "來自伺服器解釋此 cookie 功能的字串註解,或 ``None``。" #: ../../library/http.cookiejar.rst:698 -#, fuzzy msgid "" "URL linking to a comment from the server explaining the function of this " "cookie, or ``None``." -msgstr "" -"鏈接到來自伺服器的解釋此 cookie 功能的註釋的 URL,或者為 :const:`None`。" +msgstr "連結到伺服器提供之解釋此 cookie 功能的註解的 URL,或 ``None``。" #: ../../library/http.cookiejar.rst:704 -#, fuzzy msgid "" "``True`` if this cookie was received as an :rfc:`2109` cookie (that is, the " "cookie arrived in a :mailheader:`Set-Cookie` header, and the value of the " @@ -1110,11 +1084,11 @@ msgid "" "because :mod:`!http.cookiejar` may 'downgrade' RFC 2109 cookies to Netscape " "cookies, in which case :attr:`version` is 0." msgstr "" -"``True`` 如果這個 cookie 是以 :rfc:`2109` cookie 的形式收到的 (即這個 cookie " -"是在 :mailheader:`Set-Cookie` 標頭中收到的,而且在那個標頭中的 Version " -"cookie-attribute 的值是 1)。 提供這個屬性的原因是 :mod:`!http.cookiejar` 可能" -"會將 RFC 2109 cookie 「降級」 為 Netscape cookie,在這種情況下 :attr:" -"`version` 的值是 0。" +"如果這個 cookie 是以 :rfc:`2109` cookie 的形式收到的(即這個 cookie 是在 :" +"mailheader:`Set-Cookie` 標頭中收到的,且該標頭中 Version cookie 屬性的值為 " +"1),則為 ``True``。提供這個屬性的原因是,:mod:`!http.cookiejar` 可能會將 " +"RFC 2109 cookies「降級」為 Netscape cookies,在這種情況下 :attr:`version` 的" +"值為 0。" #: ../../library/http.cookiejar.rst:713 msgid "" diff --git a/library/http.server.po b/library/http.server.po index b8b056505a..76abc78457 100644 --- a/library/http.server.po +++ b/library/http.server.po @@ -74,14 +74,18 @@ msgid "" "the handler's :attr:`~socketserver.BaseRequestHandler.server` instance " "variable." msgstr "" +"此類別建立在 :class:`~socketserver.TCPServer` 類別之上,將伺服器位址儲存為名" +"為 :attr:`server_name` 和 :attr:`server_port` 的實例變數。處理程式可以存取伺" +"服器,通常是透過處理程式的 :attr:`~socketserver.BaseRequestHandler.server` 實" +"例變數。" #: ../../library/http.server.rst:47 msgid "The HTTP server's fully qualified domain name." -msgstr "" +msgstr "HTTP 伺服器的完全限定網域名稱。" #: ../../library/http.server.rst:51 msgid "The HTTP server's port number obtained from *server_address*." -msgstr "" +msgstr "HTTP 伺服器的埠號,取得自 *server_address*。" #: ../../library/http.server.rst:56 msgid "" @@ -103,6 +107,8 @@ msgid "" "The *certfile* argument is the path to the SSL certificate chain file, and " "the *keyfile* is the path to the file containing the private key." msgstr "" +"*certfile* 引數是 SSL 憑證鏈檔案的路徑,而 *keyfile* 則是包含私密金鑰之檔案的" +"路徑。" #: ../../library/http.server.rst:75 msgid "" @@ -202,6 +208,8 @@ msgid "" "then ``path`` includes the query. Using the terminology of :rfc:`3986`, " "``path`` here includes ``hier-part`` and the ``query``." msgstr "" +"包含請求路徑。如果 URL 存在查詢(query)部分,則 ``path`` 會包含該查詢。以 :" +"rfc:`3986` 的術語來說,此處的 ``path`` 包含 ``hier-part`` 和 ``query``。" #: ../../library/http.server.rst:159 msgid "" @@ -259,6 +267,9 @@ msgid "" "default with variables from :attr:`responses` based on the status code " "passed to :meth:`send_error`." msgstr "" +"指定一個格式字串,供 :meth:`send_error` 方法用來建立傳送給客戶端的錯誤回應。" +"此字串預設會依據傳遞給 :meth:`send_error` 的狀態碼,以 :attr:`responses` 中的" +"變數填入。" #: ../../library/http.server.rst:207 msgid "" @@ -318,6 +329,10 @@ msgid "" "not want the client to continue. For example, the server can choose to send " "``417 Expectation Failed`` as a response header and ``return False``." msgstr "" +"當符合 HTTP/1.1 規範的伺服器收到 ``Expect: 100-continue`` 請求標頭時,會先回" +"應 ``100 Continue``,接著再回應 ``200 OK`` 標頭。如果伺服器不希望客戶端繼續," +"可以覆寫此方法以引發錯誤。舉例來說,伺服器可以選擇傳送 ``417 Expectation " +"Failed`` 作為回應標頭,並 ``return False``。" #: ../../library/http.server.rst:261 msgid "" @@ -381,6 +396,9 @@ msgid "" "and sent directly the output stream. If the *message* is not specified, the " "HTTP message corresponding the response *code* is sent." msgstr "" +"僅傳送回應標頭,用於伺服器向客戶端傳送 ``100 Continue`` 回應的情況。這些標頭" +"不會被緩衝,而是直接傳送至輸出串流。如果未指定 *message*,則會傳送對應回應 " +"*code* 的 HTTP 訊息。" #: ../../library/http.server.rst:312 msgid "This method does not reject *message* containing CRLF sequences." @@ -424,6 +442,10 @@ msgid "" "`log_message` are applied as inputs to the formatting. The client IP address " "and current date and time are prefixed to every message logged." msgstr "" +"將任意訊息記錄到 ``sys.stderr``。通常會覆寫此方法以建立自訂的錯誤記錄機制。" +"*format* 引數是標準的 printf 風格格式字串,傳遞給 :meth:`log_message` 的額外" +"引數會作為格式化的輸入。每筆記錄的訊息前面都會加上客戶端 IP 位址與目前的日期" +"時間。" #: ../../library/http.server.rst:355 msgid "" @@ -492,11 +514,11 @@ msgstr "" #: ../../library/http.server.rst:405 msgid "Specifies the filenames that are treated as directory index pages." -msgstr "" +msgstr "指定要被視為目錄索引頁面的檔案名稱。" #: ../../library/http.server.rst:407 msgid "Defaults to ``(\"index.html\", \"index.htm\")``." -msgstr "" +msgstr "預設為 ``(\"index.html\", \"index.htm\")``。" #: ../../library/http.server.rst:413 msgid "" @@ -538,6 +560,10 @@ msgid "" "scan the directory, and returns a ``404`` error response if the :func:`~os." "listdir` fails." msgstr "" +"如果請求被對映到一個目錄,則會依照 :attr:`index_pages` 所指定的內容檢查該目錄" +"是否有索引頁面。如果找到,則回傳該檔案的內容;否則會呼叫 :meth:" +"`list_directory` 方法產生目錄列表。此方法使用 :func:`os.listdir` 掃描目錄,如" +"果 :func:`~os.listdir` 失敗,則回傳 ``404`` 錯誤回應。" #: ../../library/http.server.rst:441 msgid "" @@ -575,7 +601,7 @@ msgstr "" #: ../../library/http.server.rst:464 msgid "Helper to list the contents of *path* when no index page is present." -msgstr "" +msgstr "當沒有索引頁面時,用來列出 *path* 內容的輔助方法。" #: ../../library/http.server.rst:466 msgid "" @@ -583,16 +609,21 @@ msgid "" "caller) or ``None`` to indicate an error, in which case the caller has " "nothing further to do. In either case, the headers are sent." msgstr "" +"此方法會回傳一個\\ :term:`類檔案物件 `\\ (必須由呼叫者關" +"閉),或回傳 ``None`` 以表示發生錯誤,此時呼叫者不須再做任何事。無論哪種情" +"況,標頭都會被傳送。" #: ../../library/http.server.rst:472 msgid "Guess the type of the file at the given *path*." -msgstr "" +msgstr "猜測給定 *path* 之檔案的類型。" #: ../../library/http.server.rst:474 msgid "" "This returns a string of the form ``type/subtype``, usable for a MIME " "Content-type header." msgstr "" +"此方法會回傳一個 ``type/subtype`` 形式的字串,可用於 MIME 的 Content-type 標" +"頭。" #: ../../library/http.server.rst:477 msgid "" @@ -600,16 +631,20 @@ msgid "" "`extensions_map`, falling back to :func:`mimetypes.guess_file_type` and then " "to ``'application/octet-stream'``." msgstr "" +"預設實作會在 :attr:`extensions_map` 中查找檔案的副檔名,若查無結果則回退為 :" +"func:`mimetypes.guess_file_type`,再退而使用 ``'application/octet-stream'``。" #: ../../library/http.server.rst:482 msgid "Add :func:`mimetypes.guess_file_type` as a fallback." -msgstr "" +msgstr "新增 :func:`mimetypes.guess_file_type` 作為回退方案。" #: ../../library/http.server.rst:486 msgid "" "The :class:`SimpleHTTPRequestHandler` class can be used to create a very " "basic webserver serving files relative to the current directory as follows::" msgstr "" +":class:`SimpleHTTPRequestHandler` 類別可用於建立一個非常基本的網頁伺服器,用" +"來服務相對於目前目錄的檔案,如下所示: ::" #: ../../library/http.server.rst:489 msgid "" @@ -641,6 +676,9 @@ msgid "" "behavior, such as using different index file names by overriding the class " "attribute :attr:`~SimpleHTTPRequestHandler.index_pages`." msgstr "" +":class:`SimpleHTTPRequestHandler` 也可以被子類別化以增強其行為,例如透過覆寫" +"類別屬性 :attr:`~SimpleHTTPRequestHandler.index_pages` 來使用不同的索引檔案名" +"稱。" #: ../../library/http.server.rst:508 msgid "" @@ -671,6 +709,9 @@ msgid "" "scripts and serve the output, instead of serving files, if the request leads " "to somewhere below the ``cgi_directories`` path." msgstr "" +"如果請求指向 ``cgi_directories`` 路徑之下的某處,:func:" +"`~SimpleHTTPRequestHandler.do_GET` 和 :func:`~SimpleHTTPRequestHandler." +"do_HEAD` 函式會被修改為執行 CGI 指令碼並服務其輸出,而不是服務檔案本身。" #: ../../library/http.server.rst:530 msgid "The :class:`CGIHTTPRequestHandler` defines the following data member:" @@ -840,6 +881,8 @@ msgid "" "requests which makes it possible for files outside of the specified " "directory to be served." msgstr "" +":class:`SimpleHTTPRequestHandler` 在處理請求時會跟隨符號連結,這使得指定目錄" +"之外的檔案有可能被服務。" #: ../../library/http.server.rst:686 msgid "" @@ -848,6 +891,9 @@ msgid "" "not perform input validation such as checking for the presence of CRLF " "sequences. Untrusted input may result in HTTP header injection attacks." msgstr "" +":meth:`BaseHTTPRequestHandler.send_header` 和 :meth:`BaseHTTPRequestHandler." +"send_response_only` 方法假定輸入內容已經過清理,不會執行諸如檢查是否存在 " +"CRLF 序列之類的輸入驗證。不受信任的輸入可能導致 HTTP 標頭注入攻擊。" #: ../../library/http.server.rst:691 msgid "" diff --git a/library/imaplib.po b/library/imaplib.po index 7b957314c8..7cefd460d3 100644 --- a/library/imaplib.po +++ b/library/imaplib.po @@ -33,6 +33,10 @@ msgid "" "`3501`. It is backward compatible with IMAP4 (:rfc:`1730`) servers, but note " "that the ``STATUS`` command is not supported in IMAP4." msgstr "" +"此模組定義了三個類別::class:`IMAP4`、:class:`IMAP4_SSL` 和 :class:" +"`IMAP4_stream`,它們封裝了與 IMAP4 伺服器的連線,並實作 :rfc:`3501` 中定義的 " +"IMAP4rev1 用戶端協定之大部分子集。它向後相容於 IMAP4(:rfc:`1730`\\ )伺服" +"器,但請注意 IMAP4 不支援 ``STATUS`` 命令。" #: ../../includes/wasm-notavail.rst:3 msgid "Availability" @@ -139,6 +143,9 @@ msgid "" "certificate and hostname are not verified. To verify them, pass a context " "created by :func:`ssl.create_default_context`." msgstr "" +"在使用預設的 *ssl_context* 時,連線會被加密,但伺服器憑證與主機名稱不會被驗" +"證。若要驗證它們,請傳入由 :func:`ssl.create_default_context` 所建立的 " +"context。" #: ../../library/imaplib.rst:107 msgid "" @@ -182,6 +189,9 @@ msgid "" "response and return the corresponding local time. The return value is a :" "class:`time.struct_time` tuple or ``None`` if the input has wrong format." msgstr "" +"剖析包含 IMAP4 ``INTERNALDATE`` 回應的\\ :term:`類位元組串物件 `,並回傳對應的本地時間。回傳值是一個 :class:`time.struct_time` 元組," +"如果輸入格式錯誤則為 ``None``。" #: ../../library/imaplib.rst:146 msgid "" @@ -195,6 +205,8 @@ msgid "" "to a tuple of individual flags as :class:`bytes`. The return value is an " "empty tuple if the input has wrong format." msgstr "" +"將包含 IMAP4 ``FLAGS`` 回應的\\ :term:`類位元組串物件 ` 轉" +"換為由個別旗標組成的 :class:`bytes` 元組。如果輸入格式錯誤,回傳值為空元組。" #: ../../library/imaplib.rst:159 msgid "" @@ -253,6 +265,14 @@ msgid "" "quotes is left unchanged, so that code which quotes arguments itself keeps " "working." msgstr "" +"命令的所有引數都會被轉換為字串,但 ``AUTHENTICATE`` 除外,而 ``APPEND`` 的最" +"後一個引數會以 IMAP4 字面值的形式傳遞。如有必要(字串中含有 IMAP4 協定的敏感" +"字元,且未以括號或雙引號括起),每個字串都會被加上引號。然而,``LOGIN`` 命令" +"的 *password* 引數一律會被加上引號。如果你想避免某個引數字串被加上引號(例" +"如:``STORE`` 的 *flags* 引數),可以將該字串以括號括起(例如:" +"``r'(\\Deleted)'``\\ )。一般來說,請傳遞未加引號的引數,讓模組視需要自行為其" +"加上引號。已經以雙引號括起的引數會維持不變,因此自行為引數加上引號的程式碼仍" +"可繼續運作。" #: ../../library/imaplib.rst:203 msgid "" @@ -286,6 +306,9 @@ msgid "" "separated by spaces, for example ``r'\\Seen \\Answered'``. If *flags* is not " "already enclosed in parentheses, parentheses are added automatically." msgstr "" +"*flags* 可以是 ``None``,或是一個由 IMAP 旗標記號組成的字串。多個旗標之間以空" +"格分隔,例如 ``r'\\Seen \\Answered'``。如果 *flags* 尚未以括號括起,將會自動" +"加上括號。" #: ../../library/imaplib.rst:230 msgid "Authenticate command --- requires response processing." @@ -735,6 +758,8 @@ msgid "" "section 6.4.6 of :rfc:`3501` as being one of \"FLAGS\", \"+FLAGS\", or \"-" "FLAGS\", optionally with a suffix of \".SILENT\"." msgstr "" +"變更信箱中郵件的旗標狀態。*command* 由 :rfc:`3501` 第 6.4.6 節指定,其值為 " +"\"FLAGS\"、\"+FLAGS\" 或 \"-FLAGS\" 三者之一,並可選擇加上 \".SILENT\" 後綴。" #: ../../library/imaplib.rst:635 msgid "For example, to set the delete flag on all messages::" @@ -763,6 +788,12 @@ msgid "" "backward compatibility reasons, and as of Python 3.6, handles them if they " "are sent from the server, since this improves real-world compatibility." msgstr "" +"建立包含 ']' 的旗標(例如:\"[test]\")違反了 :rfc:`3501`\\ (IMAP 協定)。然" +"而,imaplib 一直以來都允許建立這類旗標,而像 Gmail 這樣常見的 IMAP 伺服器也會" +"接受並產生這類旗標。也有非 Python 的程式會建立這類旗標。儘管這違反了 RFC,且 " +"IMAP 用戶端與伺服器理應嚴格遵守規範,但基於向後相容的考量,imaplib 仍持續允許" +"建立這類旗標;自 Python 3.6 起,若伺服器傳來這類旗標,imaplib 也會加以處理," +"因為這樣能提升實際環境中的相容性。" #: ../../library/imaplib.rst:656 msgid "Subscribe to new mailbox." @@ -826,7 +857,7 @@ msgstr "" #: ../../library/imaplib.rst:711 msgid "A tuple of the capabilities advertised by the server, in upper case." -msgstr "" +msgstr "由伺服器所公告的功能組成的元組,皆為大寫字母。" #: ../../library/imaplib.rst:713 msgid "" @@ -835,10 +866,14 @@ msgid "" "`~IMAP4.starttls`, because the server can advertise different capabilities " "in different connection states." msgstr "" +"這個屬性會在連線建立時被設定,並在成功呼叫 :meth:`~IMAP4.login`、:meth:" +"`~IMAP4.authenticate` 或 :meth:`~IMAP4.starttls` 之後重新整理,因為伺服器在不" +"同的連線狀態下可能會公告不同的功能。" #: ../../library/imaplib.rst:719 msgid "Refreshed after :meth:`~IMAP4.login` and :meth:`~IMAP4.authenticate`." msgstr "" +"在呼叫 :meth:`~IMAP4.login` 和 :meth:`~IMAP4.authenticate` 之後會重新整理。" #: ../../library/imaplib.rst:725 msgid "" @@ -901,6 +936,8 @@ msgid "" "`3501`, section 7.4.2), so production code should inspect the whole response " "rather than rely on ``data[0][1]``." msgstr "" +"一個 ``FETCH`` 回應可能會包含額外或未經請求的資料(參閱 :rfc:`3501` 第 7.4.2 " +"節),因此正式環境中的程式碼應該檢查整個回應,而不是僅依賴 ``data[0][1]``。" #: ../../library/imaplib.rst:17 msgid "IMAP4" diff --git a/library/importlib.metadata.po b/library/importlib.metadata.po index 4ff74c0894..9221898e40 100644 --- a/library/importlib.metadata.po +++ b/library/importlib.metadata.po @@ -134,7 +134,6 @@ msgid "You can get the :ref:`metadata for a distribution `::" msgstr "" #: ../../library/importlib.metadata.rst:93 -#, fuzzy msgid "" ">>> from importlib.metadata import metadata\n" ">>> list(metadata('wheel'))\n" @@ -146,6 +145,7 @@ msgid "" "'Classifier', 'Requires-Python', 'Provides-Extra', 'Requires-Dist', " "'Requires-Dist']" msgstr "" +">>> from importlib.metadata import metadata\n" ">>> list(metadata('wheel'))\n" "['Metadata-Version', 'Name', 'Version', 'Summary', 'Home-page', 'Author', " "'Author-email', 'Maintainer', 'Maintainer-email', 'License', 'Project-URL', " diff --git a/library/importlib.po b/library/importlib.po index 1e92dcff0e..63a486d70b 100644 --- a/library/importlib.po +++ b/library/importlib.po @@ -484,10 +484,12 @@ msgid "" "get_resource_reader` method as specified by :class:`importlib.resources.abc." "ResourceReader`." msgstr "" +"想要支援資源讀取的載入器應依照 :class:`importlib.resources.abc." +"ResourceReader` 所指定的規範,實作 :meth:`!get_resource_reader` 方法。" #: ../../library/importlib.rst:316 msgid "Introduced the optional :meth:`!get_resource_reader` method." -msgstr "" +msgstr "新增了可選的 :meth:`!get_resource_reader` 方法。" #: ../../library/importlib.rst:321 msgid "" @@ -945,6 +947,9 @@ msgid "" "create_module ` and :meth:`Loader." "exec_module `" msgstr "" +"作為 :pep:`489` 的一部分,內建引入器現在實作了 :meth:`Loader.create_module " +"` 和 :meth:`Loader.exec_module " +"`" #: ../../library/importlib.rst:726 msgid "" @@ -957,6 +962,8 @@ msgid "" "Gained :meth:`~importlib.abc.Loader.create_module` and :meth:`~importlib.abc." "Loader.exec_module` methods." msgstr "" +"新增了 :meth:`~importlib.abc.Loader.create_module` 和 :meth:`~importlib.abc." +"Loader.exec_module` 方法。" #: ../../library/importlib.rst:741 msgid "" @@ -1404,6 +1411,11 @@ msgid "" "`sys.implementation.cache_tag `; if it is not defined " "then :exc:`NotImplementedError` will be raised)." msgstr "" +"回傳與原始碼 *path* 相關聯的位元組編譯檔案的 :pep:`3147`/:pep:`488` 路徑。例" +"如,若 *path* 為 ``/foo/bar/baz.py``,在 Python 3.2 中回傳值會是 ``/foo/bar/" +"__pycache__/baz.cpython-32.pyc``。``cpython-32`` 字串來自目前的 magic tag" +"(見 :attr:`sys.implementation.cache_tag `;若未定義則會" +"引發 :exc:`NotImplementedError`)。" #: ../../library/importlib.rst:1171 msgid "" @@ -1448,6 +1460,11 @@ msgid "" "cache_tag ` is not defined, :exc:`NotImplementedError` " "is raised." msgstr "" +"給定一個 :pep:`3147` 檔案名稱的 *path*,回傳其對應的原始碼檔案路徑。例如,若 " +"*path* 為 ``/foo/bar/__pycache__/baz.cpython-32.pyc``,回傳的路徑會是 ``/foo/" +"bar/baz.py``。*path* 不必實際存在,但若其不符合 :pep:`3147` 或 :pep:`488` 格" +"式,則會引發 :exc:`ValueError`。若未定義 :attr:`sys.implementation.cache_tag " +"`,則會引發 :exc:`NotImplementedError`。" #: ../../library/importlib.rst:1214 msgid "" @@ -1502,6 +1519,7 @@ msgid "" "**name** and **package** work the same as for :func:`importlib." "import_module`." msgstr "" +"**name** 和 **package** 的運作方式與 :func:`importlib.import_module` 相同。" #: ../../library/importlib.rst:1259 msgid "" @@ -1539,6 +1557,10 @@ msgid "" "meth:`InspectLoader.is_package `, to " "fill in any missing information on the spec." msgstr "" +"根據載入器建立 :class:`~importlib.machinery.ModuleSpec` 實例的工廠函式。這些" +"參數的意義與它們在 ModuleSpec 中相同。此函式會使用可用的 :term:`loader` API" +"(例如 :meth:`InspectLoader.is_package `)來補齊規格中缺少的資訊。" #: ../../library/importlib.rst:1293 msgid "" diff --git a/library/index.po b/library/index.po index 01650eabc2..9cf60a1f5f 100644 --- a/library/index.po +++ b/library/index.po @@ -22,20 +22,17 @@ msgstr "" "X-Generator: Poedit 2.4.3\n" #: ../../library/index.rst:5 -#, fuzzy msgid "The Python standard library" msgstr "Python 標準函式庫 (Standard Library)" #: ../../library/index.rst:7 -#, fuzzy msgid "" "This library reference manual describes the standard library distributed " "with Python. It also describes some of the optional components that are " "commonly included in Python distributions." msgstr "" -":ref:`reference-index`\\ 說明 Python 這門語言確切的文法及語意,而這份函式庫參" -"考手冊則是說明隨著 Python 一起發佈的標準函式庫,除此之外,其內容也包含一些時" -"常出現在 Python 發佈版本中的非必要套件。" +"這份函式庫參考手冊說明了隨 Python 一起發佈的標準函式庫,同時也說明了一些常包" +"含在 Python 發佈版本中的非必要元件。" #: ../../library/index.rst:11 msgid "" @@ -43,9 +40,10 @@ msgid "" "of the Python language, and :ref:`builtins-index` describes the built-in " "functions." msgstr "" +"另外,:ref:`reference-index` 說明了 Python 語言確切的文法及語意,而 :ref:" +"`builtins-index` 則說明了內建函式。" #: ../../library/index.rst:15 -#, fuzzy msgid "" "Python's standard library is extensive, offering a wide range of facilities " "as indicated by the long table of contents listed below. The library " diff --git a/library/inspect.po b/library/inspect.po index 9b5b131902..19be67f86d 100644 --- a/library/inspect.po +++ b/library/inspect.po @@ -837,6 +837,8 @@ msgid "" ":term:`Duck-typed ` function-like objects now return ``True`` " "if their code object has the :data:`CO_GENERATOR` flag." msgstr "" +"採用\\ :term:`鴨子型別 `\\ 的類函式物件,如果其程式碼物件具有 :" +"data:`CO_GENERATOR` 旗標,現在會回傳 ``True``。" #: ../../library/inspect.rst:475 msgid "" @@ -867,6 +869,8 @@ msgid "" ":term:`Duck-typed ` function-like objects now return ``True`` " "if their code object has the :data:`CO_COROUTINE` flag." msgstr "" +"採用\\ :term:`鴨子型別 `\\ 的類函式物件,如果其程式碼物件具有 :" +"data:`CO_COROUTINE` 旗標,現在會回傳 ``True``。" #: ../../library/inspect.rst:501 msgid "" @@ -970,6 +974,8 @@ msgid "" ":term:`Duck-typed ` function-like objects now return ``True`` " "if their code object has the :data:`CO_ASYNC_GENERATOR` flag." msgstr "" +"採用\\ :term:`鴨子型別 `\\ 的類函式物件,如果其程式碼物件具有 :" +"data:`CO_ASYNC_GENERATOR` 旗標,現在會回傳 ``True``。" #: ../../library/inspect.rst:579 msgid "" @@ -1027,6 +1033,8 @@ msgid "" "Return ``True`` if the object is a method descriptor, but not if :func:" "`isclass`, :func:`ismethod` or :func:`isfunction` is true." msgstr "" +"如果物件是方法描述器,且 :func:`isclass`、:func:`ismethod` 或 :func:" +"`isfunction` 皆不為真,則回傳 ``True``。" #: ../../library/inspect.rst:635 msgid "" @@ -1045,6 +1053,10 @@ msgid "" "example, count on having the :attr:`~method.__func__` attribute when an " "object passes :func:`ismethod`." msgstr "" +"若方法描述器同時通過其他測試中的任一項(:func:`!isclass`、:func:`!ismethod` " +"或 :func:`!isfunction`),此函式就會回傳 ``False``,這純粹是因為那些其他測試" +"提供了更多保證 -- 舉例來說,當物件通過 :func:`ismethod` 時,你可以確定它擁" +"有 :attr:`~method.__func__` 屬性。" #: ../../library/inspect.rst:647 msgid "" @@ -1059,6 +1071,8 @@ msgid "" "Return ``True`` if the object is a data descriptor, but not if :func:" "`isclass`, :func:`ismethod` or :func:`isfunction` is true." msgstr "" +"如果物件是資料描述器,且 :func:`isclass`、:func:`ismethod` 或 :func:" +"`isfunction` 皆不為真,則回傳 ``True``。" #: ../../library/inspect.rst:658 msgid "" @@ -1066,6 +1080,8 @@ msgid "" "`~object.__delete__` method. Optionally, they may also have a :meth:" "`~object.__get__` method." msgstr "" +"資料描述器總是具有 :meth:`~object.__set__` 方法和/或 :meth:`~object." +"__delete__` 方法,也可以選擇性地具有 :meth:`~object.__get__` 方法。" #: ../../library/inspect.rst:662 msgid "" @@ -1074,6 +1090,9 @@ msgid "" "extension modules), more specific tests are available: :func:" "`isgetsetdescriptor` and :func:`ismemberdescriptor`, respectively." msgstr "" +"資料描述器的範例包括 :func:`property `、getset 和成員描述器。請注" +"意,對於後兩者(僅在 C 擴充模組中定義),有更具體的測試可用:分別是 :func:" +"`isgetsetdescriptor` 和 :func:`ismemberdescriptor`。" #: ../../library/inspect.rst:667 msgid "" @@ -1081,6 +1100,8 @@ msgid "" "`!__doc__` attributes (as properties, getsets and member descriptors do), " "this is not necessarily the case in general." msgstr "" +"雖然資料描述器也可能具有 :attr:`~definition.__name__` 和 :attr:`!__doc__` 屬" +"性(如同 property、getset 和成員描述器一樣),但一般而言不一定如此。" #: ../../library/inspect.rst:671 msgid "" @@ -1090,6 +1111,10 @@ msgid "" "__delete__`, but not :meth:`~object.__set__`, are now properly recognized as " "data descriptors as well, which was not the case previously." msgstr "" +"此函式現在會將僅具有 :meth:`~object.__set__` 方法的物件視為資料描述器(不再需" +"要同時具備 :meth:`~object.__get__`)。此外,具有 :meth:`~object.__delete__` " +"但不具有 :meth:`~object.__set__` 的物件,現在也能被正確識別為資料描述器,而這" +"在先前版本中並非如此。" #: ../../library/inspect.rst:680 msgid "Return ``True`` if the object is a getset descriptor." @@ -1146,6 +1171,9 @@ msgid "" "will fail with a :exc:`TypeError` if the object is a built-in module, class, " "or function." msgstr "" +"回傳定義該物件的(文字或二進位)檔案的名稱。如果無法取得原始碼,則會引發 :" +"exc:`OSError`。如果該物件是內建模組、類別或函式,則會引發 :exc:`TypeError` 而" +"失敗。" #: ../../library/inspect.rst:736 msgid "" @@ -1160,6 +1188,9 @@ msgid "" "is raised if the source code cannot be retrieved. This will fail with a :exc:" "`TypeError` if the object is a built-in module, class, or function." msgstr "" +"回傳定義該物件的 Python 原始碼檔案名稱;如果無法識別取得原始碼的方式,則回傳 " +"``None``。如果無法取得原始碼,則會引發 :exc:`OSError`。如果該物件是內建模組、" +"類別或函式,則會引發 :exc:`TypeError` 而失敗。" #: ../../library/inspect.rst:751 msgid "" diff --git a/library/intro.po b/library/intro.po index 8764dbd1fc..bc33635923 100644 --- a/library/intro.po +++ b/library/intro.po @@ -27,7 +27,6 @@ msgid "Introduction" msgstr "簡介" #: ../../library/intro.rst:7 -#, fuzzy msgid "" "The Python standard library consists of a collection of modules. There are " "many ways to dissect this collection. Most modules are written in Python, " @@ -42,17 +41,15 @@ msgid "" "particular configuration option was chosen at the time when Python was " "compiled and installed." msgstr "" -"整個函式庫中包含了許多模組,有許多方法可以從函式庫中取用這些模組。有些模組是" -"以 C 語言撰寫並建置於 Python 直譯器之中,其他的是由 Python 撰寫並以源碼的方" -"式 (source form) 引入。有些模組提供的功能是專屬於 Python 的,像是把 stack " -"trace 印出來;有些則是針對特定作業系統,去試著存取特定硬體;還有些提供對特定" -"應用的功能與操作介面,像是 World Wide Web。模組的使用情況會因機器與 Python 的" -"版本而不同,部分模組是開放所有版本以及 Port 的 Python 來使用的,但有些會因系" -"統支援或需求在某些版本或系統下無法使用,甚至有些僅限在特定的設定環境下才能使" -"用。" +"Python 標準函式庫由一系列模組所組成,而檢視這些模組的方式有很多種。大多數模組" +"是以 Python 撰寫,但也有一些是以 C 語言撰寫;它們都可以被引入到你的程式中以增" +"添功能。有些模組提供的介面是專屬於 Python 的,像是印出 stack trace(堆疊追" +"蹤);有些提供的介面則是針對特定作業系統,例如存取特定硬體;還有些提供的介面" +"是針對特定應用領域,像是網頁開發。有些模組可用於所有版本與移植版的 Python;有" +"些則只在底層系統支援或要求時才可用;還有些僅在編譯與安裝 Python 時選擇了特定" +"的設定選項後才可用。" #: ../../library/intro.rst:19 -#, fuzzy msgid "" "If you start reading this manual from the start, and skip to the next " "chapter when you get bored, you will get a reasonable overview of the " @@ -67,17 +64,19 @@ msgid "" msgstr "" "這代表如果你從這個手冊的最開始讀起,並在感到無聊時跳到下一個章節,你仍然可以" "得到一個對 Python 函式庫所支援的模組與其合理應用的概觀。當然,你\\ *沒有必要" -"*\\ 像是在讀一本小說一樣讀這本手冊——你可以快速瀏覽目錄(在手冊的最前頭)、或" -"是你可以利用最後面的索引來查詢特定的函式或模組。最後,如果你享受閱讀一些隨機" -"的主題,你可以選擇一個隨機的數字並開始閱讀(見 :mod:`random` 模組) 。不管你想" -"要以什麼順序來閱讀這個手冊,:ref:`built-in-funcs`\\ 會是一個很好的入門,因為" -"手冊中其他章節都預設你已經對這個章節有一定的熟悉程度。" +"*\\ 像是在讀一本小說一樣讀這本手冊——你可以快速瀏覽目錄(在手冊的最前頭),或" +"是利用最後面的索引來查詢特定的函式、模組或術語。最後,如果你喜歡隨意瀏覽各種" +"主題,也可以隨意翻開一頁,閱讀其中一兩個小節。不管你想要以什麼順序來閱讀這個" +"手冊,先讀過\\ :ref:`built-in-funcs`\\ 會是個好的開始,因為手冊中其他章節都預" +"設你已經對這個章節有一定的熟悉程度。" #: ../../library/intro.rst:33 msgid "" "The built-in functions and classes (which can be used without an :keyword:" "`import` statement) are described in :ref:`builtins-index`." msgstr "" +"內建函式與類別(可以不需要 :keyword:`import` 陳述式即可使用)在 :ref:" +"`builtins-index` 中有詳細說明。" #: ../../library/intro.rst:40 msgid "Notes on availability" diff --git a/library/itertools.po b/library/itertools.po index bc2f8c29c8..2ee7d9d74b 100644 --- a/library/itertools.po +++ b/library/itertools.po @@ -562,7 +562,6 @@ msgstr "" "如果 *strict* 為真,則當最後一個批次比 *n* 短時,會引發 :exc:`ValueError`。" #: ../../library/itertools.rst:161 -#, fuzzy msgid "" "Loops over the input iterable and accumulates data into tuples up to size " "*n*. The input is consumed lazily, just enough to fill a batch. The result " @@ -571,7 +570,7 @@ msgid "" msgstr "" "對輸入的可疊代物件進行迴圈,並將資料累積到大小為 *n* 的元組中。輸入是惰性地被" "消耗 (consumed lazily) 的,會剛好足夠填充一批的資料。一旦批次填滿或輸入的可疊" -"代物件耗盡,就會 yield 出結果:" +"代物件\\ :term:`耗盡 `,就會 yield 出結果:" #: ../../library/itertools.rst:166 msgid "" @@ -612,16 +611,15 @@ msgid "Added the *strict* option." msgstr "新增 *strict* 選項。" #: ../../library/itertools.rst:193 -#, fuzzy msgid "" "Make an iterator that returns elements from the first iterable until it is :" "term:`exhausted`, then proceeds to the next iterable, until all of the " "iterables are exhausted. This combines multiple data sources into a single " "iterator. Roughly equivalent to::" msgstr "" -"建立一個疊代器,從第一個可疊代物件回傳元素直到其耗盡,然後繼續處理下一個可疊" -"代物件,直到所有可疊代物件都耗盡。這將多個資料來源結合為單一個疊代器。大致等" -"價於: ::" +"建立一個疊代器,從第一個可疊代物件回傳元素直到其\\ :term:`耗盡 `," +"然後繼續處理下一個可疊代物件,直到所有可疊代物件都耗盡。這將多個資料來源結合" +"為單一個疊代器。大致等價於: ::" #: ../../library/itertools.rst:198 msgid "" @@ -811,14 +809,14 @@ msgstr "" " yield tuple(pool[i] for i in indices)" #: ../../library/itertools.rst:301 -#, fuzzy msgid "" "Make an iterator that returns elements from *data* where the corresponding " "element in *selectors* is true. Stops when either the *data* or *selectors* " "iterables have been :term:`exhausted`. Roughly equivalent to::" msgstr "" "建立一個疊代器,回傳 *data* 中對應 *selectors* 的元素為 true 的元素。當 " -"*data* 或 *selectors* 可疊代物件耗盡時停止。大致等價於: ::" +"*data* 或 *selectors* 可疊代物件\\ :term:`耗盡 `\\ 時停止。大致等" +"價於: ::" #: ../../library/itertools.rst:306 msgid "" @@ -871,14 +869,14 @@ msgid "Added *step* argument and allowed non-integer arguments." msgstr "新增 *step* 引數並允許非整數引數。" #: ../../library/itertools.rst:338 -#, fuzzy msgid "" "Make an iterator returning elements from the *iterable* and saving a copy of " "each. When the iterable is :term:`exhausted`, return elements from the " "saved copy. Repeats indefinitely. Roughly equivalent to::" msgstr "" -"建立一個疊代器,回傳 *iterable* 中的元素並保存每個元素的副本。當可疊代物件耗" -"盡時,從保存的副本中回傳元素。會無限次的重複。大致等價於: ::" +"建立一個疊代器,回傳 *iterable* 中的元素並保存每個元素的副本。當可疊代物件" +"\\ :term:`耗盡 `\\ 時,從保存的副本中回傳元素。會無限次的重複。大" +"致等價於: ::" #: ../../library/itertools.rst:342 msgid "" @@ -1127,13 +1125,12 @@ msgstr "" "過 iterable 中的元素。" #: ../../library/itertools.rst:469 -#, fuzzy msgid "" "If *stop* is ``None``, iteration continues until the input is :term:" "`exhausted`, if at all. Otherwise, it stops at the specified position." msgstr "" -"如果 *stop* 為 ``None``,則疊代將繼續前進直到輸入耗盡。如果指定了 *stop*,則" -"在達到指定位置時停止。" +"如果 *stop* 為 ``None``,則疊代將繼續前進直到輸入\\ :term:`耗盡 " +"`。如果指定了 *stop*,則在達到指定位置時停止。" #: ../../library/itertools.rst:472 msgid "" @@ -1514,7 +1511,6 @@ msgstr "" " yield x" #: ../../library/itertools.rst:672 -#, fuzzy msgid "" "Note, the element that first fails the predicate condition is consumed from " "the input iterator and there is no way to access it. This could be an issue " @@ -1525,10 +1521,10 @@ msgid "" "before_and_after>`__ instead." msgstr "" "注意,第一個不符合條件判斷的元素將從輸入疊代器中被消耗,且無法再存取它。如果" -"應用程式希望在 *takewhile* 耗盡後進一步消耗輸入疊代器,這可能會是個問題。為了" -"解決這個問題,可以考慮使用 `more-itertools 中的 before_and_after() `_ 作為替代。" +"應用程式希望在 *takewhile* 執行至\\ :term:`耗盡 `\\ 後,繼續消耗輸" +"入疊代器,這可能會是個問題。為了解決這個問題,可以考慮使用 `more-itertools 中" +"的 before_and_after() `_ 作為替代。" #: ../../library/itertools.rst:683 msgid "Return *n* independent iterators from a single iterable." @@ -1685,9 +1681,8 @@ msgstr "" "*fillvalue* 會預設為 ``None``。" #: ../../library/itertools.rst:764 -#, fuzzy msgid "Iteration continues until the longest iterable is :term:`exhausted`." -msgstr "疊代將持續直到最長的可疊代物件耗盡為止。" +msgstr "疊代將持續直到最長的可疊代物件\\ :term:`耗盡 `\\ 為止。" #: ../../library/itertools.rst:768 msgid "" diff --git a/library/json.po b/library/json.po index 812cbc0501..8f5436bbfe 100644 --- a/library/json.po +++ b/library/json.po @@ -434,7 +434,6 @@ msgstr "" "class:`str`。這個引數的作用與 :func:`dump` 中的同名引數意義相同。" #: ../../library/json.rst:261 -#, fuzzy msgid "" "Keys in key/value pairs of JSON are always of the type :class:`str`. When a " "dictionary is converted into JSON, all the keys of the dictionary are " @@ -447,7 +446,8 @@ msgstr "" "JSON 鍵/值對中的鍵始終為 :class:`str` 型別。當字典被轉換為 JSON 時,字典的所" "有鍵值資料型別都會被強制轉換為字串。因此,如果將字典先轉換為 JSON 格式然後再" "轉換回字典,則該字典可能不等於原始字典。也就是說,如果字典 x 含有非字串鍵值," -"則 ``loads(dumps(x)) != x``。" +"則 ``loads(dumps(x)) != x``。*sort_keys* 會在鍵被強制轉換為字串之前先將它們排" +"序,因此數值鍵會依其值排序,而非依其字串表示法排序。" #: ../../library/json.rst:274 msgid "" diff --git a/library/logging.config.po b/library/logging.config.po index c44bacb492..005cb11de4 100644 --- a/library/logging.config.po +++ b/library/logging.config.po @@ -811,7 +811,6 @@ msgid "" msgstr "" #: ../../library/logging.config.rst:556 -#, fuzzy msgid "" "{\n" " '()' : 'my.package.customFormatterFactory',\n" @@ -829,7 +828,7 @@ msgstr "" " 'bar' : 'baz',\n" " 'spam' : 99.9,\n" " 'answer' : 42,\n" -" '.' {\n" +" '.' : {\n" " 'foo': 'bar',\n" " 'baz': 'bozz'\n" " }\n" diff --git a/library/lzma.po b/library/lzma.po index 7651ec6fa5..a1b707d749 100644 --- a/library/lzma.po +++ b/library/lzma.po @@ -218,6 +218,8 @@ msgid "" "Possible values are :const:`FORMAT_XZ` (the default), :const:`FORMAT_ALONE` " "and :const:`FORMAT_RAW`." msgstr "" +"*format* 引數指定應使用的容器格式。可能的值為 :const:`FORMAT_XZ`\\ (預設" +"值)、:const:`FORMAT_ALONE` 和 :const:`FORMAT_RAW`\\ 。" #: ../../library/lzma.rst:161 msgid "" @@ -227,6 +229,10 @@ msgid "" "`CHECK_CRC32`, :const:`CHECK_CRC64` (the default for :const:`FORMAT_XZ`) " "and :const:`CHECK_SHA256`." msgstr "" +"*check* 引數指定要包含在壓縮資料中的完整性檢查類型。此檢查會在解壓縮時使用," +"以確保資料未遭到損毀。可能的值為 :const:`CHECK_NONE`、:const:`CHECK_CRC32`、:" +"const:`CHECK_CRC64`\\ (:const:`FORMAT_XZ` 的預設值)和 :const:" +"`CHECK_SHA256`\\ 。" #: ../../library/lzma.rst:167 msgid "" @@ -472,34 +478,28 @@ msgid "Branch-Call-Jump (BCJ) filters:" msgstr "" #: ../../library/lzma.rst:341 -#, fuzzy msgid ":const:`!FILTER_X86`" -msgstr ":const:`FILTER_X86`" +msgstr ":const:`!FILTER_X86`" #: ../../library/lzma.rst:342 -#, fuzzy msgid ":const:`!FILTER_IA64`" -msgstr ":const:`FILTER_IA64`" +msgstr ":const:`!FILTER_IA64`" #: ../../library/lzma.rst:343 -#, fuzzy msgid ":const:`!FILTER_ARM`" -msgstr ":const:`FILTER_ARM`" +msgstr ":const:`!FILTER_ARM`" #: ../../library/lzma.rst:344 -#, fuzzy msgid ":const:`!FILTER_ARMTHUMB`" -msgstr ":const:`FILTER_ARMTHUMB`" +msgstr ":const:`!FILTER_ARMTHUMB`" #: ../../library/lzma.rst:345 -#, fuzzy msgid ":const:`!FILTER_POWERPC`" -msgstr ":const:`FILTER_POWERPC`" +msgstr ":const:`!FILTER_POWERPC`" #: ../../library/lzma.rst:346 -#, fuzzy msgid ":const:`!FILTER_SPARC`" -msgstr ":const:`FILTER_SPARC`" +msgstr ":const:`!FILTER_SPARC`" #: ../../library/lzma.rst:348 msgid "" @@ -583,27 +583,31 @@ msgstr "" #: ../../library/lzma.rst:384 msgid "Constants" -msgstr "" +msgstr "常數" #: ../../library/lzma.rst:386 msgid "" "The following module-level constants are provided for use as the *format*, " "*check*, *preset* and *filters* arguments of the classes and functions above." msgstr "" +"以下模組層級的常數可用作上述類別與函式的 *format* 、*check* 、*preset* 和 " +"*filters* 引數。" #: ../../library/lzma.rst:389 msgid "Container formats:" -msgstr "" +msgstr "容器格式:" #: ../../library/lzma.rst:393 msgid "The ``.xz`` container format." -msgstr "" +msgstr "``.xz`` 容器格式。" #: ../../library/lzma.rst:397 msgid "" "The legacy ``.lzma`` container format. This format is more limited than ``." "xz`` -- it does not support integrity checks or multiple filters." msgstr "" +"舊版的 ``.lzma`` 容器格式。此格式比 ``.xz`` 更為受限——它不支援完整性檢查或多" +"個過濾器。" #: ../../library/lzma.rst:402 msgid "" @@ -613,36 +617,43 @@ msgid "" "data compressed in this manner cannot be decompressed using :const:" "`FORMAT_AUTO`." msgstr "" +"一個不使用任何容器格式的原始資料串流。此格式指定符不支援完整性檢查,且要求你" +"必須始終指定自訂的過濾器鏈(用於壓縮和解壓縮兩者)。此外,以此方式壓縮的資料" +"無法使用 :const:`FORMAT_AUTO` 解壓縮。" #: ../../library/lzma.rst:410 msgid "" "Used for decompression only. The container format is detected " "automatically, so that both ``.xz`` and ``.lzma`` files can be decompressed." msgstr "" +"僅用於解壓縮。容器格式會被自動偵測,因此 ``.xz`` 和 ``.lzma`` 檔案皆可被解壓" +"縮。" #: ../../library/lzma.rst:413 msgid "Integrity checks:" -msgstr "" +msgstr "完整性檢查:" #: ../../library/lzma.rst:417 msgid "" "No integrity check. This is the default (and the only acceptable value) " "for :const:`FORMAT_ALONE` and :const:`FORMAT_RAW`." msgstr "" +"沒有完整性檢查。這是 :const:`FORMAT_ALONE` 和 :const:`FORMAT_RAW` 的預設值" +"(也是唯一可接受的值)。" #: ../../library/lzma.rst:422 msgid "A 32-bit Cyclic Redundancy Check." -msgstr "" +msgstr "32 位元的循環冗餘核對。" #: ../../library/lzma.rst:426 msgid "" "A 64-bit Cyclic Redundancy Check. This is the default for :const:" "`FORMAT_XZ`." -msgstr "" +msgstr "64 位元的循環冗餘核對。這是 :const:`FORMAT_XZ` 的預設值。" #: ../../library/lzma.rst:431 msgid "A 256-bit Secure Hash Algorithm." -msgstr "" +msgstr "256 位元的安全雜湊演算法。" #: ../../library/lzma.rst:435 msgid "" @@ -650,28 +661,32 @@ msgid "" "be the value of the :attr:`LZMADecompressor.check` attribute until enough of " "the input has been decoded." msgstr "" +"串流所使用的完整性檢查尚無法確定。在輸入被解碼足夠多之前,這可能是 :attr:" +"`LZMADecompressor.check` 屬性的值。" #: ../../library/lzma.rst:441 msgid "The largest supported integrity-check ID." -msgstr "" +msgstr "支援的最大完整性檢查 ID。" #: ../../library/lzma.rst:443 msgid "Compression presets:" -msgstr "" +msgstr "壓縮預設值:" #: ../../library/lzma.rst:447 msgid "The default compression preset, equivalent to preset level ``6``." -msgstr "" +msgstr "預設的壓縮預設值,相當於預設等級 ``6``。" #: ../../library/lzma.rst:451 msgid "" "A flag that may be bitwise OR-ed with a preset level (``0`` to ``9``) to " "select a slower but more thorough variant of that preset." msgstr "" +"一個可以與預設等級(``0`` 到 ``9``)進行位元 OR 運算的旗標,用來選擇該預設等" +"級中速度較慢但更徹底的變體。" #: ../../library/lzma.rst:454 msgid "Filter IDs and options:" -msgstr "" +msgstr "過濾器 ID 與選項:" #: ../../library/lzma.rst:459 msgid "" @@ -679,22 +694,29 @@ msgid "" "with :const:`FORMAT_ALONE`, while :const:`FILTER_LZMA2` is for use with :" "const:`FORMAT_XZ` and :const:`FORMAT_RAW`." msgstr "" +"LZMA1 和 LZMA2 壓縮過濾器。:const:`FILTER_LZMA1` 用於 :const:" +"`FORMAT_ALONE`\\ ,而 :const:`FILTER_LZMA2` 則用於 :const:`FORMAT_XZ` 和 :" +"const:`FORMAT_RAW`\\ 。" #: ../../library/lzma.rst:465 msgid "The delta filter." -msgstr "" +msgstr "差量過濾器。" #: ../../library/lzma.rst:470 msgid "" "Compression modes that may be used as the ``mode`` option of a filter " "specifier (see :ref:`filter-chain-specs`)." msgstr "" +"可用作過濾器指定符 ``mode`` 選項的壓縮模式(請參閱 :ref:`filter-chain-" +"specs`\\ )。" #: ../../library/lzma.rst:479 msgid "" "Match finders that may be used as the ``mf`` option of a filter specifier " "(see :ref:`filter-chain-specs`)." msgstr "" +"可用作過濾器指定符 ``mf`` 選項的比對查找器(請參閱 :ref:`filter-chain-" +"specs`\\ )。" #: ../../library/lzma.rst:484 msgid "Examples" diff --git a/library/mimetypes.po b/library/mimetypes.po index 592d08eff1..c49b19926b 100644 --- a/library/mimetypes.po +++ b/library/mimetypes.po @@ -90,7 +90,7 @@ msgstr "新增 *url* 做為 :term:`path-like object` 的支援。" #: ../../library/mimetypes.rst:59 msgid "" "Passing a file path instead of URL. Use :func:`guess_file_type` for this." -msgstr "" +msgstr "傳遞檔案路徑而非 URL。請改用 :func:`guess_file_type`。" #: ../../library/mimetypes.rst:68 msgid "" @@ -166,6 +166,10 @@ msgid "" "(``'.'``), to strings of the form ``'type/subtype'``. If the file does not " "exist or cannot be read, ``None`` is returned." msgstr "" +"如果名為 *file* 的檔案存在,則載入其中給定的型別對映表。*file* 必須是指定欲讀" +"取檔案名稱的字串。型別對映表會以字典的形式回傳,將包含開頭句點(``'.'``)的副" +"檔名對映到形式為 ``'type/subtype'`` 的字串。如果該檔案不存在或無法讀取,則回" +"傳 ``None``。" #: ../../library/mimetypes.rst:132 msgid "" @@ -265,6 +269,10 @@ msgid "" "also be cleared before loading additional data if the default data is not " "desired." msgstr "" +"這個類別代表一個 MIME 型別資料庫。在預設情況下,它會存取和此模組其他部分相同" +"的資料庫。初始資料庫是由 Python 內建的 MIME 型別表建立的。可以使用 :meth:" +"`read` 或 :meth:`readfp` 方法,將額外的 :file:`mime.types`\\ 風格檔案載入資料" +"庫來擴充它。如果不需要預設資料,也可以在載入額外資料之前先清除對映字典。" #: ../../library/mimetypes.rst:212 msgid "" @@ -280,12 +288,16 @@ msgid "" "`.tar.gz` to allow the encoding and type to be recognized separately. This " "is initialized with some predefined values." msgstr "" +"將副檔名對映到副檔名的字典。這是用來辨識那些編碼和型別由同一個副檔名表示的已" +"編碼檔案。舉例來說,:file:`.tgz` 副檔名會被對映到 :file:`.tar.gz`,以便能分別" +"辨識編碼和型別。這個字典會以一些預先定義的值初始化。" #: ../../library/mimetypes.rst:227 msgid "" "Dictionary mapping filename extensions to encoding types. This is " "initialized with some predefined values." msgstr "" +"將檔案名稱副檔名對映到編碼類型的字典。這個字典會以一些預先定義的值初始化。" #: ../../library/mimetypes.rst:233 msgid "" @@ -295,6 +307,9 @@ msgid "" "values and MIME type information loaded from files specified by the " "*filenames* argument." msgstr "" +"包含兩個字典的元組,將檔案名稱副檔名對映到 MIME 型別:第一個字典用於非標準型" +"別,第二個字典用於標準型別。它們會以一些預先定義的值,以及從 *filenames* 引數" +"所指定的檔案載入的 MIME 型別資訊來初始化。" #: ../../library/mimetypes.rst:242 msgid "" @@ -304,6 +319,9 @@ msgid "" "predefined values and MIME type information loaded from files specified by " "the *filenames* argument." msgstr "" +"包含兩個字典的元組,將 MIME 型別對映到副檔名串列:第一個字典用於非標準型別," +"第二個字典用於標準型別。它們會以一些預先定義的值,以及從 *filenames* 引數所指" +"定的檔案載入的 MIME 型別資訊來初始化。" #: ../../library/mimetypes.rst:251 msgid "" diff --git a/library/multiprocessing.po b/library/multiprocessing.po index 28084888f0..47f5aa5abc 100644 --- a/library/multiprocessing.po +++ b/library/multiprocessing.po @@ -3677,7 +3677,7 @@ msgstr "" #: ../../library/multiprocessing.rst:2531 msgid "An iterator-based version of :meth:`.map`." -msgstr "" +msgstr "一個以疊代器為基礎的 :meth:`.map` 版本。" #: ../../library/multiprocessing.rst:2533 msgid "" diff --git a/library/numbers.po b/library/numbers.po index 040dd7e9d2..e72e9a00f4 100644 --- a/library/numbers.po +++ b/library/numbers.po @@ -145,15 +145,13 @@ msgid "Notes for type implementers" msgstr "給型別實作者的註記" #: ../../library/numbers.rst:91 -#, fuzzy msgid "" "Implementers should be careful to make equal numbers equal and hash them to " "the same values. This may be subtle if there are two different extensions of " "the real numbers. See also :ref:`numeric-hash`." msgstr "" -"實作者需注意,相等的數值除了大小相等外,還必須擁有同樣的雜湊值。當使用兩個不" -"同的實數擴充時,這可能是很微妙的。例如,:class:`fractions.Fraction` 底下的 :" -"func:`hash` 實作如下: ::" +"實作者應謹慎地讓相等的數值相等,並將它們雜湊為相同的值。若存在兩種不同的實數" +"擴充,這可能會很微妙。另請參閱 :ref:`numeric-hash`。" #: ../../library/numbers.rst:97 msgid "Adding More Numeric ABCs" diff --git a/library/os.path.po b/library/os.path.po index b786415f7a..f0a0a8368a 100644 --- a/library/os.path.po +++ b/library/os.path.po @@ -116,6 +116,9 @@ msgid "" "drive, and the drive letter is capitalized. Trailing dots and spaces are " "stripped. For example::" msgstr "" +"在 Windows 上,路徑會由作業系統正規化,因此結果可能與 ``normpath(join(os." +"getcwd(), path))`` 不同。驅動機相對路徑會相對於指定驅動機的目前目錄進行解析," +"且驅動機字母會轉為大寫。結尾的點號和空格會被移除。例如: ::" #: ../../library/os.path.rst:69 msgid "" @@ -124,6 +127,10 @@ msgid "" ">>> os.path.abspath('c:/temp/spam. . .')\n" "'c:\\\\temp\\\\spam'" msgstr "" +">>> os.path.abspath('c:spam')\n" +"'C:\\\\Temp\\\\spam'\n" +">>> os.path.abspath('c:/temp/spam. . .')\n" +"'c:\\\\temp\\\\spam'" #: ../../library/os.path.rst:74 msgid ":func:`os.path.join` and :func:`os.path.normpath`." @@ -587,7 +594,6 @@ msgstr "" "個字元。" #: ../../library/os.path.rst:438 -#, fuzzy msgid "" "Return the canonical path of the specified filename, eliminating any " "symbolic links encountered in the path (if they are supported by the " @@ -599,7 +605,8 @@ msgid "" msgstr "" "回傳指定檔案名稱的規範路徑,會消除路徑中遇到的所有符號連結(如果作業系統支" "援)。在 Windows 上,此函式還會解析 MS-DOS(也稱為 8.3)樣式的名稱,例如 ``C:" -"\\\\PROGRA~1`` 會被解析為 ``C:\\\\Program Files``。" +"\\\\PROGRA~1`` 會被解析為 ``C:\\\\Program Files``。回傳的路徑會使用作業系統回" +"報的大小寫,這可能與 *path* 的大小寫不同,特別是驅動機字母會轉為大寫。" #: ../../library/os.path.rst:446 msgid "" diff --git a/library/os.po b/library/os.po index b9e777ddde..558336430c 100644 --- a/library/os.po +++ b/library/os.po @@ -926,7 +926,7 @@ msgstr "" msgid "" "Returns information identifying the current operating system. The return " "value is a :class:`uname_result`." -msgstr "" +msgstr "回傳識別目前作業系統的資訊,回傳值是一個 :class:`uname_result`。" #: ../../library/os.rst:796 msgid "" @@ -935,10 +935,13 @@ msgid "" "uname` can be used to get the user-facing operating system name and release " "on iOS and Android." msgstr "" +"在 macOS、iOS 和 Android 上,這會回傳核心名稱及其發行版本(即在 macOS 和 iOS " +"上為 ``'Darwin'``;在 Android 上為 ``'Linux'``)。在 iOS 和 Android 上,可以" +"使用 :func:`platform.uname` 來取得面向使用者的作業系統名稱和發行版本。" #: ../../library/os.rst:802 msgid ":data:`sys.platform` which has finer granularity." -msgstr "" +msgstr ":data:`sys.platform`,其粒度更精細。" #: ../../library/os.rst:809 ../../library/os.rst:5247 msgid "" @@ -951,6 +954,8 @@ msgid "" "Name and information about the system returned by :func:`os.uname`. These " "attributes correspond to the members described in :manpage:`uname(2)`." msgstr "" +"由 :func:`os.uname` 回傳的系統名稱與相關資訊。這些屬性對應於 :manpage:" +"`uname(2)` 中描述的成員。" #: ../../library/os.rst:819 msgid "" @@ -959,11 +964,14 @@ msgid "" "nodename`, :attr:`~uname_result.release`, :attr:`~uname_result.version`, " "and :attr:`~uname_result.machine` in that order." msgstr "" +"為了向後相容,此物件也是可疊代的,其行為就像一個依序包含 :attr:" +"`~uname_result.sysname`、:attr:`~uname_result.nodename`、:attr:" +"`~uname_result.release`、:attr:`~uname_result.version` 和 :attr:" +"`~uname_result.machine` 的五元組。" #: ../../library/os.rst:827 -#, fuzzy msgid "Operating system name." -msgstr ":attr:`sysname` - 作業系統名稱" +msgstr "作業系統名稱。" #: ../../library/os.rst:831 msgid "" @@ -972,19 +980,21 @@ msgid "" "the hostname is :func:`socket.gethostname` or even ``socket." "gethostbyaddr(socket.gethostname())``." msgstr "" +"網路上的機器名稱。有些系統會將 :attr:`~uname_result.nodename` 截斷為 8 個字元" +"或僅保留開頭的部分;取得主機名稱較好的方式是使用 :func:`socket.gethostname`," +"甚至是 ``socket.gethostbyaddr(socket.gethostname())``。" #: ../../library/os.rst:838 msgid "Operating system release." -msgstr "" +msgstr "作業系統發行版本。" #: ../../library/os.rst:842 -#, fuzzy msgid "Operating system version." -msgstr ":attr:`version` - 作業系統版本" +msgstr "作業系統版本。" #: ../../library/os.rst:846 msgid "Hardware identifier." -msgstr "" +msgstr "硬體識別碼。" #: ../../library/os.rst:853 msgid "" @@ -1298,6 +1308,9 @@ msgid "" "file descriptor *fd* in a :class:`statvfs_result`, like :func:`statvfs`. As " "of Python 3.3, this is equivalent to ``os.statvfs(fd)``." msgstr "" +"以 :class:`statvfs_result` 回傳檔案描述器 *fd* 所關聯檔案所在檔案系統的相關資" +"訊,就像 :func:`statvfs` 一樣。自 Python 3.3 起,這等同於 ``os." +"statvfs(fd)``。" #: ../../library/os.rst:1136 msgid "" @@ -2365,6 +2378,8 @@ msgid "" "The :func:`contextlib.chdir` context manager, which changes the current " "working directory on entering and restores the previous one on exit." msgstr "" +":func:`contextlib.chdir` 情境管理器會在進入時變更目前工作目錄,並在退出時還原" +"為先前的目錄。" #: ../../library/os.rst:2158 msgid "" @@ -3217,6 +3232,9 @@ msgid "" "garbage collected, or when an error happens during iterating. However it is " "advisable to call it explicitly or use the :keyword:`with` statement." msgstr "" +"當疊代器已\\ :term:`耗盡 `\\ 或被垃圾回收時,又或是在疊代過程中發" +"生錯誤時,會自動呼叫此函式。但建議明確地呼叫它,或使用 :keyword:`with` 陳述" +"式。" #: ../../library/os.rst:2909 msgid "" @@ -3336,6 +3354,14 @@ msgid "" "`scandir` *path* argument was a :ref:`file descriptor `, the :attr:" "`path` attribute is the same as the :attr:`name` attribute." msgstr "" +"該項目的路徑名稱:相當於 ``os.path.join(scandir_path, entry.name)``,其中 " +"*scandir_path* 是原始的 :func:`scandir` *path* 引數。除了檔案名稱之外,此路徑" +"會保留原始的 :func:`scandir` 引數。如果 :func:`scandir` 的 *path* 引數是相對" +"路徑,:attr:`path` 屬性也會是相對路徑。在建立 :func:`scandir` 疊代器之後變更" +"目前工作目錄,可能會導致之後使用 :attr:`path` 時解析出不同的結果。在某些平台" +"上,如果原始的 :func:`scandir` 引數可用於列舉,但不可用於與項目名稱組合,則建" +"構出的路徑可能無效。如果 :func:`scandir` 的 *path* 引數是\\ :ref:`檔案描述器 " +"`,則 :attr:`path` 屬性會與 :attr:`name` 屬性相同。" #: ../../library/os.rst:2996 msgid "" @@ -3871,46 +3897,51 @@ msgid "" "on the given path and correspond to the members of the :c:struct:`statvfs` " "structure." msgstr "" +"對給定的路徑執行 :manpage:`statvfs(3)` 系統呼叫。回傳值是一個 :class:" +"`statvfs_result`,其屬性描述給定路徑所在的檔案系統,並對應到 :c:struct:" +"`statvfs` 結構的成員。" #: ../../library/os.rst:3428 msgid "" "Filesystem statistics returned by :func:`os.statvfs` and :func:`os." "fstatvfs`. See :manpage:`statvfs(3)` for more details." msgstr "" +"由 :func:`os.statvfs` 和 :func:`os.fstatvfs` 回傳的檔案系統統計資訊。更多細節" +"請見 :manpage:`statvfs(3)`。" #: ../../library/os.rst:3433 msgid "Block size." -msgstr "" +msgstr "區塊大小。" #: ../../library/os.rst:3437 msgid "Fragment size." -msgstr "" +msgstr "片段大小。" #: ../../library/os.rst:3441 msgid "" "Number of :attr:`~statvfs_result.f_frsize` sized blocks the filesystem can " "contain." -msgstr "" +msgstr "檔案系統可容納的 :attr:`~statvfs_result.f_frsize` 大小區塊數量。" #: ../../library/os.rst:3446 msgid "Number of free blocks." -msgstr "" +msgstr "可用區塊數量。" #: ../../library/os.rst:3450 msgid "Number of free blocks for unprivileged users." -msgstr "" +msgstr "非特權使用者可用的區塊數量。" #: ../../library/os.rst:3454 msgid "Number of file entries, inodes, the filesystem can contain." -msgstr "" +msgstr "檔案系統可容納的檔案項目(inode)數量。" #: ../../library/os.rst:3458 msgid "Number of free files entries." -msgstr "" +msgstr "可用檔案項目數量。" #: ../../library/os.rst:3462 msgid "Number of free file entries for unprivileged users." -msgstr "" +msgstr "非特權使用者可用的檔案項目數量。" #: ../../library/os.rst:3466 msgid "" @@ -3920,6 +3951,10 @@ msgid "" "data:`ST_IMMUTABLE`, :data:`ST_NOATIME`, :data:`ST_NODIRATIME`, and :data:" "`ST_RELATIME`." msgstr "" +"掛載旗標的位元遮罩。定義了以下旗標::data:`ST_RDONLY`、:data:`ST_NOSUID`、:" +"data:`ST_NODEV`、:data:`ST_NOEXEC`、:data:`ST_SYNCHRONOUS`、:data:" +"`ST_MANDLOCK`、:data:`ST_WRITE`、:data:`ST_APPEND`、:data:`ST_IMMUTABLE`、:" +"data:`ST_NOATIME`、:data:`ST_NODIRATIME` 和 :data:`ST_RELATIME`。" #: ../../library/os.rst:3474 msgid "" @@ -3927,62 +3962,64 @@ msgid "" "`Windows MAX_PATH ` and those described in Linux :manpage:" "`pathname(7)` may exist." msgstr "" +"檔案系統的最大檔名長度。可能會有作業系統特定的限制,例如 :ref:`Windows " +"MAX_PATH ` 以及 Linux :manpage:`pathname(7)` 中所描述的限制。" #: ../../library/os.rst:3480 msgid "Filesystem ID." -msgstr "" +msgstr "檔案系統 ID。" #: ../../library/os.rst:3485 msgid "The following flags are used in :attr:`statvfs_result.f_flag`." -msgstr "" +msgstr "以下旗標用於 :attr:`statvfs_result.f_flag`。" #: ../../library/os.rst:3489 msgid "Read-only filesystem." -msgstr "" +msgstr "唯讀檔案系統。" #: ../../library/os.rst:3495 msgid "Setuid/setgid bits are disabled or not supported." -msgstr "" +msgstr "Setuid/setgid 位元已停用或不受支援。" #: ../../library/os.rst:3501 msgid "Disallow access to device special files." -msgstr "" +msgstr "不允許存取裝置特殊檔案。" #: ../../library/os.rst:3509 msgid "Disallow program execution." -msgstr "" +msgstr "不允許執行程式。" #: ../../library/os.rst:3517 msgid "Writes are synced at once." -msgstr "" +msgstr "寫入會立即同步。" #: ../../library/os.rst:3525 msgid "Allow mandatory locks on an FS." -msgstr "" +msgstr "允許在檔案系統上使用強制鎖。" #: ../../library/os.rst:3533 msgid "Write on file/directory/symlink." -msgstr "" +msgstr "可對檔案、目錄或符號連結進行寫入。" #: ../../library/os.rst:3541 msgid "Append-only file." -msgstr "" +msgstr "僅附加檔案。" #: ../../library/os.rst:3549 msgid "Immutable file." -msgstr "" +msgstr "不可變檔案。" #: ../../library/os.rst:3557 msgid "Do not update access times." -msgstr "" +msgstr "不更新存取時間。" #: ../../library/os.rst:3565 msgid "Do not update directory access times." -msgstr "" +msgstr "不更新目錄存取時間。" #: ../../library/os.rst:3573 msgid "Update atime relative to mtime/ctime." -msgstr "" +msgstr "相對於 mtime/ctime 更新 atime。" #: ../../library/os.rst:3582 msgid "" @@ -4620,6 +4657,9 @@ msgid "" "to be updated. To cancel the timer when the system clock is changed, see :" "const:`TFD_TIMER_CANCEL_ON_SET`." msgstr "" +"如果 *clockid* 為 :const:`time.CLOCK_REALTIME`,則會使用一個可設定的系統級即" +"時時鐘。若系統時鐘被變更,則需要更新計時器設定。若要在系統時鐘變更時取消計時" +"器,請參閱 :const:`TFD_TIMER_CANCEL_ON_SET`。" #: ../../library/os.rst:4146 msgid "" @@ -4633,6 +4673,8 @@ msgid "" "If *clockid* is :const:`time.CLOCK_BOOTTIME`, it is the same as :const:`time." "CLOCK_MONOTONIC` except it includes any time that the system is suspended." msgstr "" +"如果 *clockid* 為 :const:`time.CLOCK_BOOTTIME`,則其與 :const:`time." +"CLOCK_MONOTONIC` 相同,但會包含系統暫停期間所經過的任何時間。" #: ../../library/os.rst:4154 msgid "" @@ -4656,6 +4698,10 @@ msgid "" "there hasn't been an expiration since the last call to read, :func:`read` " "raises :class:`OSError` with ``errno`` set to :const:`errno.EAGAIN`." msgstr "" +"如果未將 :const:`TFD_NONBLOCK` 設為旗標,則 :func:`read` 會阻塞直到計時器到期" +"為止。如果將其設為旗標,則 :func:`read` 不會阻塞,但如果自上次呼叫 read 以來" +"尚未發生到期,:func:`read` 會引發 :class:`OSError`,其 ``errno`` 會被設為 :" +"const:`errno.EAGAIN`。" #: ../../library/os.rst:4167 msgid ":const:`TFD_CLOEXEC` is always set by Python automatically." @@ -4703,10 +4749,13 @@ msgid "" "raises an :class:`OSError` exception with ``errno`` set to :const:`errno." "EINVAL`." msgstr "" +"將 *initial* 設為零 (``0``) 可停用計時器。如果 *initial* 大於零,則計時器會被" +"啟用。如果 *initial* 小於零,則會引發 :class:`OSError` 例外,其 ``errno`` 會" +"被設為 :const:`errno.EINVAL`。" #: ../../library/os.rst:4198 msgid "By default the timer will fire when *initial* seconds have elapsed." -msgstr "" +msgstr "預設情況下,計時器會在經過 *initial* 秒後觸發。" #: ../../library/os.rst:4200 msgid "" @@ -4724,6 +4773,10 @@ msgid "" "than zero, it raises :class:`OSError` with ``errno`` set to :const:`errno." "EINVAL`." msgstr "" +"計時器的間隔由 *interval* 這個 :py:class:`float` 設定。如果 *interval* 為零," +"則計時器只會在初次到期時觸發一次。如果 *interval* 大於零,則計時器會在每次自" +"上次到期後經過 *interval* 秒時觸發。如果 *interval* 小於零,則會引發 :class:" +"`OSError`,其 ``errno`` 會被設為 :const:`errno.EINVAL`。" #: ../../library/os.rst:4211 msgid "" @@ -4733,6 +4786,10 @@ msgid "" "changed discontinuously. Reading the descriptor is aborted with the error :" "const:`errno.ECANCELED`." msgstr "" +"如果 :const:`TFD_TIMER_CANCEL_ON_SET` 旗標與 :const:`TFD_TIMER_ABSTIME` 一同" +"被設定,且該計時器的時鐘為 :const:`time.CLOCK_REALTIME`,則當即時時鐘被不連續" +"地變更時,該計時器會被標記為可取消。讀取該描述器將會因錯誤 :const:`errno." +"ECANCELED` 而中止。" #: ../../library/os.rst:4217 msgid "" diff --git a/library/pdb.po b/library/pdb.po index fc779912dd..b73cbe96f4 100644 --- a/library/pdb.po +++ b/library/pdb.po @@ -1333,7 +1333,6 @@ msgstr "" "``exceptions `` 切換到該例外。" #: ../../library/pdb.rst:821 -#, fuzzy msgid "" "def out():\n" " try:\n" @@ -1367,7 +1366,7 @@ msgstr "" "def inner(x):\n" " 1 / x\n" "\n" -" out()" +"out()" #: ../../library/pdb.rst:838 msgid "calling ``pdb.pm()`` will allow to move between exceptions::" diff --git a/library/platform.po b/library/platform.po index 29630c82ca..c7777cb4cb 100644 --- a/library/platform.po +++ b/library/platform.po @@ -234,6 +234,8 @@ msgid "" "On iOS and Android, this is the user-facing OS release. To obtain the Darwin " "or Linux kernel release, use :func:`os.uname`." msgstr "" +"在 iOS 和 Android 上,這是面向使用者的 OS 版本。若要取得 Darwin 或 Linux 核心" +"版本,請使用 :func:`os.uname`。" #: ../../library/platform.rst:152 msgid "" diff --git a/library/pyexpat.po b/library/pyexpat.po index 888dd7cf15..30255b3e6f 100644 --- a/library/pyexpat.po +++ b/library/pyexpat.po @@ -45,10 +45,9 @@ msgid "" msgstr "" #: ../../library/pyexpat.rst:40 -#, fuzzy msgid "" "This module provides the following exception, type object and data items:" -msgstr "這個模組提供一個例外和一個型別物件:" +msgstr "這個模組提供以下例外、型別物件和資料項目:" #: ../../library/pyexpat.rst:45 msgid "" @@ -68,13 +67,15 @@ msgstr "" msgid "" "The version string of the Expat library loaded by the interpreter, like " "``'expat_2.8.4'``." -msgstr "" +msgstr "直譯器所載入的 Expat 函式庫版本字串,例如 ``'expat_2.8.4'``。" #: ../../library/pyexpat.rst:67 msgid "" "The version of the Expat library loaded by the interpreter, as a tuple of " "three integers: major, minor and micro version." msgstr "" +"直譯器所載入的 Expat 函式庫版本,以三個整數組成的元組表示:主版本、次版本和微" +"版本。" #: ../../library/pyexpat.rst:73 msgid "" @@ -85,6 +86,11 @@ msgid "" "``'XML_DTD'`` and ``'XML_NS'``, the value is ``0`` and only the presence of " "the name is significant." msgstr "" +"以 ``(name, value)`` 對組成的串列,列出所載入的 Expat 函式庫在編譯時啟用的功" +"能。只有本身帶有值的功能,其 value 才有意義,例如 ``'XML_CONTEXT_BYTES'`` 或" +"預設的保護限制 ``'XML_BLAP_ACT_THRES'`` 和 ``'XML_AT_MAX_AMP'``;至於其他功" +"能,例如 ``'XML_DTD'`` 和 ``'XML_NS'``,其 value 則為 ``0``,只有名稱是否存在" +"才具有意義。" #: ../../library/pyexpat.rst:81 msgid "The :mod:`!xml.parsers.expat` module contains two functions:" @@ -171,6 +177,9 @@ msgid "" "elements and attributes, and is available as the :attr:`~xmlparser.intern` " "attribute. By default a new empty dictionary is created for every parser." msgstr "" +"如果有給定 *intern*,則它必須是一個字典。這個字典用來駐留 (intern) 元素和屬性" +"的名稱,並可以透過 :attr:`~xmlparser.intern` 屬性來存取。在預設情況下,每個剖" +"析器都會建立一個新的空字典。" #: ../../library/pyexpat.rst:141 msgid "" @@ -206,6 +215,11 @@ msgid "" "file in fragments, not the submission of multiple files. *data* can be empty " "at any time." msgstr "" +"剖析 *data* 的內容,並呼叫適當的處理函式來處理剖析後的資料。*data* 可以是一個" +"\\ :term:`類位元組串物件 `\\ 或字串。如果是字串,則會忽略 " +"XML 資料中的編碼宣告,並將資料視為已解碼的文字來剖析。在最後一次呼叫此方法" +"時,*isfinal* 必須為真;這讓單一檔案可以分段剖析,而不是用來提交多個檔案。" +"*data* 在任何時候都可以是空的。" #: ../../library/pyexpat.rst:176 msgid "" @@ -214,6 +228,9 @@ msgid "" "when there's no more data. Text files are not supported; use :meth:`Parse` " "for data which is already decoded." msgstr "" +"從物件 *file* 讀取並剖析 XML 資料。*file* 只需要提供 ``read(nbytes)`` 方法," +"該方法回傳 bytes,並在沒有更多資料時回傳一個空的 bytes 物件。不支援文字檔案;" +"對於已經解碼的資料,請使用 :meth:`Parse`。" #: ../../library/pyexpat.rst:185 msgid "" @@ -239,6 +256,10 @@ msgid "" "generated by a large amount of text, not all of it may be available. When " "called while an event handler is not active, the return value is ``None``." msgstr "" +"以 :class:`bytes` 物件回傳產生目前事件的輸入資料。此資料的編碼與包含該文字的" +"實體 (entity) 相同。它會延伸到目前緩衝輸入的結尾,因此也可能包含後續事件的資" +"料;如果該事件是由大量文字所產生的,則可能無法取得全部資料。若在事件處理函式" +"未啟用時呼叫,則回傳值為 ``None``。" #: ../../library/pyexpat.rst:213 msgid "" @@ -329,19 +350,21 @@ msgstr ":class:`!xmlparser` 物件擁有以下方法來調整對一些常見 XML msgid "" "Sets the number of output bytes needed to activate protection against " "`billion laughs`_ attacks." -msgstr "" +msgstr "設定啟用\\ `billion laughs`_ 攻擊防護所需的輸出位元組數。" #: ../../library/pyexpat.rst:289 msgid "" "The number of output bytes includes amplification from entity expansion and " "reading DTD files." -msgstr "" +msgstr "此輸出位元組數包含了由實體擴展和讀取 DTD 檔案所產生的放大量。" #: ../../library/pyexpat.rst:292 msgid "" "Parser objects usually have a protection activation threshold of 8 MiB, but " "the actual default value depends on the underlying Expat library." msgstr "" +"剖析器物件通常具有 8 MiB 的防護啟用閾值,但實際的預設值取決於底層的 Expat 函" +"式庫。" #: ../../library/pyexpat.rst:295 ../../library/pyexpat.rst:347 msgid "" @@ -355,12 +378,14 @@ msgid "" "Activation thresholds below 4 MiB are known to break support for DITA 1.3 " "payload and are hence not recommended." msgstr "" +"已知低於 4 MiB 的啟用閾值會破壞對 DITA 1.3 酬載(payload)的支援,因此不建議" +"使用。" #: ../../library/pyexpat.rst:309 msgid "" "Sets the maximum tolerated amplification factor for protection against " "`billion laughs`_ attacks." -msgstr "" +msgstr "設定\\ `billion laughs`_ 攻擊防護所能容許的最大放大係數。" #: ../../library/pyexpat.rst:312 msgid "" @@ -369,6 +394,9 @@ msgid "" "document in parsing and ``indirect`` is the number of bytes added by " "expanding entities and reading of external DTD files." msgstr "" +"放大係數在剖析過程中以 ``(direct + indirect) / direct`` 計算,其中 " +"``direct`` 是剖析主要文件時所讀取的位元組數,``indirect`` 則是展開實體和讀取" +"外部 DTD 檔案所增加的位元組數。" #: ../../library/pyexpat.rst:317 msgid "" @@ -378,12 +406,17 @@ msgid "" "benign files in practice. In particular, the activation threshold should be " "carefully chosen to avoid false positives." msgstr "" +"*max_factor* 值必須是大於或等於 1.0 且非 NaN 的\\ :class:`float` 值。實務上," +"即使是良性的小型檔案,也曾觀察到整個酬載的峰值放大係數達到 15,000,而在剖析過" +"程中甚至曾達到 30,000。因此,應謹慎選擇啟用閾值以避免誤判。" #: ../../library/pyexpat.rst:323 ../../library/pyexpat.rst:369 msgid "" "Parser objects usually have a maximum amplification factor of 100, but the " "actual default value depends on the underlying Expat library." msgstr "" +"剖析器物件通常具有 100 的最大放大係數,但實際的預設值取決於底層的 Expat 函式" +"庫。" #: ../../library/pyexpat.rst:326 ../../library/pyexpat.rst:372 msgid "" @@ -399,6 +432,9 @@ msgid "" "can be adjusted by :meth:`." "SetBillionLaughsAttackProtectionActivationThreshold` is exceeded." msgstr "" +"只有在超過可透過 :meth:`." +"SetBillionLaughsAttackProtectionActivationThreshold` 調整的閾值時,才會考慮最" +"大放大係數。" #: ../../library/pyexpat.rst:341 msgid "" @@ -411,6 +447,8 @@ msgid "" "Parser objects usually have an allocation activation threshold of 64 MiB, " "but the actual default value depends on the underlying Expat library." msgstr "" +"剖析器物件通常具有 64 MiB 的記憶體分配啟用閾值,但實際的預設值取決於底層的 " +"Expat 函式庫。" #: ../../library/pyexpat.rst:356 msgid "" @@ -496,6 +534,8 @@ msgid "" "either the dictionary passed as the *intern* argument of :func:" "`ParserCreate`, or a new dictionary created for this parser." msgstr "" +"用來駐留 (intern) 元素和屬性名稱的字典。它可以是作為 :func:`ParserCreate` 的 " +"*intern* 引數所傳入的字典,也可以是為此剖析器新建立的字典。" #: ../../library/pyexpat.rst:444 msgid "" @@ -504,6 +544,9 @@ msgid "" "namespace separator. Names which have no prefix are not affected. By " "default, this attribute is false; it may be changed at any time." msgstr "" +"如果設定為真值,且啟用了命名空間處理,則命名空間前綴會作為展開名稱的第三個部" +"分回報,並以命名空間分隔符號隔開。沒有前綴的名稱不受影響。在預設情況下,這個" +"屬性為假;它可以在任何時候被改變。" #: ../../library/pyexpat.rst:451 msgid "" @@ -572,6 +615,10 @@ msgid "" "be ``1`` if the document is declared standalone, ``0`` if it is declared not " "to be standalone, or ``-1`` if the standalone clause was omitted." msgstr "" +"當 XML 宣告被剖析時呼叫。XML 宣告是(選擇性的)宣告所適用的 XML 建議版本、文" +"件文字的編碼,以及選擇性的「standalone」宣告。*version* 和 *encoding* 會是字" +"串;而如果文件被宣告為 standalone,則 *standalone* 為 ``1``,若被宣告為非 " +"standalone,則為 ``0``,若省略了 standalone 子句,則為 ``-1``。" #: ../../library/pyexpat.rst:519 msgid "" @@ -581,10 +628,14 @@ msgid "" "if specified, or ``None`` if omitted. *has_internal_subset* will be true if " "the document contains an internal document declaration subset." msgstr "" +"當 Expat 開始剖析文件型別宣告(``|$)`` 是一個不好的電子郵件匹配模式,它會匹配 " -"``''`` 和 ``'user@host.com'``,但不會匹配 ``''``。" +"``''`` 和 ``'user@host.com'``,但不會完整匹配 ``''``\\ (:func:`re.search` 在前者中只找到 " +"``'user@host.com'``\\ )。" #: ../../library/re.rst:519 msgid "" diff --git a/library/secrets.po b/library/secrets.po index c180f9bf41..583cf7572d 100644 --- a/library/secrets.po +++ b/library/secrets.po @@ -202,7 +202,6 @@ msgid "Other functions" msgstr "其他函式" #: ../../library/secrets.rst:138 -#, fuzzy msgid "" "Return ``True`` if strings or :term:`bytes-like objects ` " "*a* and *b* are equal, otherwise ``False``, using a \"constant-time " @@ -211,9 +210,10 @@ msgid "" "See :func:`hmac.compare_digest` for additional details." msgstr "" "如果字串或\\ :term:`類位元組串物件 ` *a* 與 *b* 相等則回" -"傳 ``True``,否則回傳 ``False``,以\"恆定時間比較 (constant-time compare) " -"\"的處理方式可降低\\ `時序攻擊 `_\\ 的風險。 請參閱 :func:`hmac.compare_digest` 以了解更多細節。" +"傳 ``True``,否則回傳 ``False``,以恆定時間比較(constant-time compare)的方" +"式來降低\\ `時序攻擊 `__\\ 的風險。請參閱 :func:`hmac." +"compare_digest` 以了解更多細節。" #: ../../library/secrets.rst:147 msgid "Recipes and best practices" diff --git a/library/shutil.po b/library/shutil.po index 7d987d1731..a152a8ae5d 100644 --- a/library/shutil.po +++ b/library/shutil.po @@ -514,12 +514,18 @@ msgid "" "*copy_function*, in which case *src* is copied to the destination using " "*copy_function* and then removed." msgstr "" +"當 *src* 與目的地位於同一個檔案系統時,內部會優先使用 :func:`os.rename`。如" +"果 :func:`os.rename` 因 :exc:`OSError` 而失敗(例如:使用者對目的地檔案有寫入" +"權限,但對其父目錄沒有),此方法會改用 *copy_function* 作為後備方案;在這種情" +"況下,*src* 會使用 *copy_function* 被複製到目的地,然後再被移除。" #: ../../library/shutil.rst:397 msgid "" "In case of symlinks, a new symlink pointing to the target of *src* will be " "created in or as the destination, and *src* will be removed." msgstr "" +"如果是符號連結,會在目的地中(或作為目的地本身)建立一個指向 *src* 目標的新符" +"號連結,然後 *src* 會被移除。" #: ../../library/shutil.rst:400 msgid "" diff --git a/library/site.po b/library/site.po index 3493944b0f..2cce9a6fcc 100644 --- a/library/site.po +++ b/library/site.po @@ -304,10 +304,13 @@ msgid "" "depending on the system environment, and will return a list of full paths, " "which are not checked for existence." msgstr "" +"對於 *prefixes* 中的每個目錄(若 *prefixes* 為 ``None`` 則使用 :data:" +"`PREFIXES`),此函式會依系統環境找出其 site-packages 子目錄,並回傳一個包含完" +"整路徑的串列。" #: ../../library/site.rst:255 msgid "Added the optional *prefixes* parameter." -msgstr "" +msgstr "新增可選參數 *prefixes*。" #: ../../library/site.rst:261 msgid "" diff --git a/library/socket.po b/library/socket.po index 9f3a2e47fd..2583e2fb23 100644 --- a/library/socket.po +++ b/library/socket.po @@ -955,6 +955,8 @@ msgid "" "The :class:`socket ` class constructor creates a new socket " "directly; see :ref:`socket-objects` for its parameters and full description." msgstr "" +":class:`socket ` 類別建構函式會直接建立一個新的 socket;其參數" +"和完整說明請參閱 :ref:`socket-objects`。" #: ../../library/socket.rst:846 msgid "" @@ -1689,6 +1691,12 @@ msgid "" "`socket.fromfd`, *fileno* will return the same socket and not a duplicate. " "This may help close a detached socket using :meth:`~socket.socket.close`." msgstr "" +"如果指定了 *fileno*,*family*、*type* 和 *proto* 的值會從指定的 file " +"descriptor 自動偵測。可以透過明確指定 *family*、*type* 或 *proto* 引數來覆寫" +"自動偵測的結果。這僅會影響 Python 表示方式(例如 :meth:`socket.getpeername` " +"的回傳值),而不會影響實際的作業系統資源。與 :func:`socket.fromfd` 不同," +"*fileno* 會回傳相同的 socket 而非其複本,這有助於使用 :meth:`~socket.socket." +"close` 關閉已分離的 socket。" #: ../../library/socket.rst:1488 msgid "" @@ -1752,6 +1760,8 @@ msgid "" "Support for the :term:`context manager` protocol was added. Exiting the " "context manager is equivalent to calling :meth:`~socket.socket.close`." msgstr "" +"新增了情境管理器協定的支援。離開情境管理器等同於呼叫 :meth:`~socket.socket." +"close`。" #: ../../library/socket.rst:1536 msgid "" @@ -1811,7 +1821,7 @@ msgstr "" msgid "" ":exc:`OSError` is now raised if an error occurs when the underlying :c:func:" "`!close` call is made." -msgstr "" +msgstr "現在如果呼叫底層 :c:func:`!close` 時發生錯誤,會引發 :exc:`OSError`。" #: ../../library/socket.rst:1580 msgid "" @@ -1861,6 +1871,10 @@ msgid "" "of the :c:data:`errno` variable. This is useful to support, for example, " "asynchronous connects." msgstr "" +"與 ``connect(address)`` 類似,但在 C 層級的 :c:func:`!connect` 呼叫回傳錯誤" +"時,會回傳錯誤指示值而不是引發例外(其他問題,例如「host not found」,仍然可" +"能引發例外)。若操作成功,錯誤指示值為 ``0``,否則為 :c:data:`errno` 變數的" +"值。這對於支援非同步連線等情況相當有用。" #: ../../library/socket.rst:1624 msgid "" @@ -1990,6 +2004,8 @@ msgid "" "original socket unless all other file objects have been closed and :meth:" "`~socket.socket.close` has been called on the socket object." msgstr "" +"關閉 :meth:`makefile` 所回傳的檔案物件並不會關閉原始的 socket,除非所有其他檔" +"案物件都已關閉,且已對該 socket 物件呼叫過 :meth:`~socket.socket.close`。" #: ../../library/socket.rst:1760 msgid "" @@ -2081,6 +2097,9 @@ msgid "" "conditions such as unrelated control messages being received). See also :" "meth:`sendmsg`. ::" msgstr "" +"在支援 :const:`!SCM_RIGHTS` 機制的系統上,以下函式最多可以接收 *maxfds* 個檔" +"案描述符,並回傳訊息資料和包含這些描述符的串列(同時忽略如收到不相關控制訊息" +"等非預期情況)。另請參閱 :meth:`sendmsg`。 ::" #: ../../library/socket.rst:1848 msgid "" @@ -2239,6 +2258,8 @@ msgid "" "const:`AF_UNIX` socket, on systems which support the :const:`!SCM_RIGHTS` " "mechanism. See also :meth:`recvmsg`. ::" msgstr "" +"以下函式會在支援 :const:`!SCM_RIGHTS` 機制的系統上,透過 :const:`AF_UNIX` " +"socket 傳送檔案描述符串列 *fds*。另請參閱 :meth:`recvmsg`。 ::" #: ../../library/socket.rst:2006 msgid "" @@ -2323,6 +2344,10 @@ msgid "" "completed. If zero is given, the socket is put in non-blocking mode. If " "``None`` is given, the socket is put in blocking mode." msgstr "" +"為阻塞的 socket 操作設定超時時間。*value* 引數可以是表示秒數的非負實數,或 " +"``None``。如果給定非零值,當操作尚未完成而超過超時期間 *value* 時,後續的 " +"socket 操作將引發 :exc:`timeout` 例外。如果給定零,則 socket 會被設為非阻塞模" +"式。如果給定 ``None``,則 socket 會被設為阻塞模式。" #: ../../library/socket.rst:2082 msgid "" @@ -2348,6 +2373,13 @@ msgid "" "*optlen* argument is required. It's equivalent to calling :c:func:`!" "setsockopt` C function with ``optval=NULL`` and ``optlen=optlen``." msgstr "" +"設定給定 socket 選項的值(請參閱 Unix 使用手冊 :manpage:`setsockopt(2)`)。所" +"需的符號常數已在此模組中定義(:ref:`!SO_\\* etc. `)。" +"此值可以是整數、``None``,或表示緩衝區的\\ :term:`類位元組串物件 `。在後者的情況下,呼叫者需自行確保該位元組字串包含正確的位元(可選的" +"內建模組 :mod:`struct` 提供了將 C 結構編碼為位元組字串的方法)。當 *value* 設" +"為 ``None`` 時,需提供 *optlen* 引數。這相當於以 ``optval=NULL`` 和 " +"``optlen=optlen`` 呼叫 C 函式 :c:func:`!setsockopt`。" #: ../../library/socket.rst:2107 msgid "setsockopt(level, optname, None, optlen: int) form added." @@ -2377,6 +2409,8 @@ msgid "" "Note that there are no methods :meth:`!read` or :meth:`!write`; use :meth:" "`~socket.recv` and :meth:`~socket.send` without *flags* argument instead." msgstr "" +"請注意,這裡沒有 :meth:`!read` 或 :meth:`!write` 方法;請改用不帶 *flags* 引" +"數的 :meth:`~socket.recv` 和 :meth:`~socket.send`。" #: ../../library/socket.rst:2140 msgid "" @@ -2403,6 +2437,10 @@ msgid "" "is true, but ``SocketType`` is not the same as ``type(socket(...))``, which " "is :class:`~socket.socket` itself." msgstr "" +":class:`~socket.socket` 型別的基底類別,從 :mod:`!_socket` 重新匯出。諸如 " +"``isinstance(socket(...), SocketType)`` 這樣的實例檢查會為真,但 " +"``SocketType`` 和 ``type(socket(...))`` 並不相同,後者即為 :class:`~socket." +"socket` 本身。" #: ../../library/socket.rst:2170 msgid "Notes on socket timeouts" diff --git a/library/stdtypes.po b/library/stdtypes.po index 0a6d130e71..fb12b0f652 100644 --- a/library/stdtypes.po +++ b/library/stdtypes.po @@ -1240,7 +1240,6 @@ msgid "[sign] ['0x'] integer ['.' fraction] ['p' exponent]" msgstr "[sign] ['0x'] integer ['.' fraction] ['p' exponent]" #: ../../library/stdtypes.rst:709 -#, fuzzy msgid "" "where the optional ``sign`` may be either ``+`` or ``-``, ``integer`` and " "``fraction`` are strings of hexadecimal digits, and ``exponent`` is a " @@ -1719,7 +1718,7 @@ msgstr "" #: ../../library/stdtypes.rst:1002 msgid "" "See :ref:`time-complexity` for the costs of the various sequence operations." -msgstr "" +msgstr "各種序列操作的成本請參閱\\ :ref:`time-complexity`\\ 。" #: ../../library/stdtypes.rst:1020 msgid "``x in s``" @@ -2206,6 +2205,8 @@ msgid "" "Retrieve the item at *index* and also remove it from *sequence*. By default, " "the last item in *sequence* is removed and returned." msgstr "" +"取出 *sequence* 中位於 *index* 的項目並將其從 *sequence* 中移除。預設情況下," +"會移除並回傳 *sequence* 中的最後一個項目。" #: ../../library/stdtypes.rst:1363 msgid "Remove the first item from *sequence* where ``sequence[i] == value``." @@ -2930,24 +2931,20 @@ msgid ":meth:`bytes.rstrip`" msgstr ":meth:`bytes.rstrip`" #: ../../library/stdtypes.rst:1729 -#, fuzzy msgid ":meth:`str.removeprefix`" -msgstr ":meth:`str.replace`" +msgstr ":meth:`str.removeprefix`" #: ../../library/stdtypes.rst:1729 -#, fuzzy msgid ":meth:`bytes.removeprefix`" -msgstr ":meth:`bytes.replace`" +msgstr ":meth:`bytes.removeprefix`" #: ../../library/stdtypes.rst:1731 -#, fuzzy msgid ":meth:`str.removesuffix`" -msgstr ":meth:`str.rfind`" +msgstr ":meth:`str.removesuffix`" #: ../../library/stdtypes.rst:1731 -#, fuzzy msgid ":meth:`bytes.removesuffix`" -msgstr ":meth:`bytes.rfind`" +msgstr ":meth:`bytes.removesuffix`" #: ../../library/stdtypes.rst:1733 msgid "Translation and Encoding" @@ -3510,6 +3507,12 @@ msgid "" "the Unicode Standard `_. For example:" msgstr "" +"如果字串中所有字元皆為字母字元且至少有一個字元,則回傳 ``True``,否則回傳 " +"``False``。字母字元是指在 Unicode 字元資料庫中被定義為「Letter」的字元,也就" +"是一般類別屬性為「Lm」、「Lt」、「Lu」、「Ll」或「Lo」其中之一的字元。請注" +"意,這與\\ `Unicode 標準第 4.10 節「Letters, Alphabetic, and Ideographic」中" +"定義的 Alphabetic 屬性 `_\\ 不同。例如:" #: ../../library/stdtypes.rst:2133 msgid "" @@ -3586,6 +3589,11 @@ msgid "" "Kharosthi#Numerals>`__. Formally, a digit is a character that has the " "property value Numeric_Type=Digit or Numeric_Type=Decimal." msgstr "" +"如果字串中所有字元皆為數字,且至少有一個字元,則回傳 ``True``,否則回傳 " +"``False``。數字包括十進位字元,以及需要特殊處理的數字,例如相容性上標數字。這" +"涵蓋了無法用來組成十進位數字的數字,例如\\ `佉盧文數字 `__\\ 。正式來說,數字是指具有 " +"Numeric_Type=Digit 或 Numeric_Type=Decimal 屬性值的字元。" #: ../../library/stdtypes.rst:2190 ../../library/stdtypes.rst:2271 #: ../../library/stdtypes.rst:2288 ../../library/stdtypes.rst:2315 @@ -4144,6 +4152,11 @@ msgid "" "the right, :meth:`rsplit` behaves like :meth:`split` which is described in " "detail below." msgstr "" +"回傳字串中由字詞組成的 list,並以 *sep* 作為分隔字串。如果有給定 *maxsplit*," +"則最多進行 *maxsplit* 次分割,且從\\ *最右邊*\\ 開始分割。如果未指定 *sep* 或" +"其為 ``None``,則任何\\ :meth:`空白字元 `\\ 字串都會被視為分隔" +"符。除了從右邊開始分割之外,:meth:`rsplit` 的行為與下方詳述的 :meth:`split` " +"相同。" #: ../../library/stdtypes.rst:2601 msgid "" @@ -4236,6 +4249,10 @@ msgid "" "Consequently, splitting an empty string or a string consisting of just " "whitespace with a ``None`` separator returns ``[]``." msgstr "" +"如果未指定 *sep* 或其為 ``None``,則會套用不同的分割演算法:連續的\\ :meth:`" +"空白字元 `\\ 會被視為單一分隔符,並且如果字串開頭或結尾有空白字" +"元,結果中不會包含空字串。因此,以 ``None`` 作為分隔符來分割空字串或僅由空白" +"字元組成的字串,會回傳 ``[]``。" #: ../../library/stdtypes.rst:2663 msgid "" @@ -4867,7 +4884,6 @@ msgid "" msgstr "" #: ../../library/stdtypes.rst:3034 -#, fuzzy msgid "" ">>> from fractions import Fraction\n" ">>> one_third = Fraction(1, 3)\n" @@ -4886,7 +4902,7 @@ msgstr "" "'0.333333'\n" ">>> f'{one_third:_^+10}'\n" "'___+1/3___'\n" -">>> >>> f'{one_third!r:_^20}'\n" +">>> f'{one_third!r:_^20}'\n" "'___Fraction(1, 3)___'\n" ">>> f'{one_third = :~>10}~'\n" "'one_third = ~~~~~~~1/3~'" @@ -4900,12 +4916,16 @@ msgid "" "A :dfn:`t-string` (formally a :dfn:`template string literal`) is a string " "literal that is prefixed with ``t`` or ``T``." msgstr "" +":dfn:`t 字串`\\ (正式名稱為\\ :dfn:`模板字串字面值`\\ )是以 ``t`` 或 ``T`` " +"為前綴的字串字面值。" #: ../../library/stdtypes.rst:3053 msgid "" "These strings follow the same syntax and evaluation rules as :ref:`formatted " "string literals `, with the following differences:" msgstr "" +"這些字串遵循與\\ :ref:`格式化字串字面值 `\\ 相同的語法和求" +"值規則,但有以下差異:" #: ../../library/stdtypes.rst:3057 msgid "" @@ -4943,6 +4963,11 @@ msgid "" "conversion or format specifier is provided, this will override the default " "behaviour." msgstr "" +"當插值運算式中提供了等號 ``'='`` 時,該運算式的文字會被附加到相關插值前面的字" +"面字串中,這包括等號本身以及其周圍的所有空白字元。該運算式的 :class:`!" +"Interpolation` 實例會如常建立,唯一的差別是 :attr:`~string.templatelib." +"Interpolation.conversion` 預設會被設為 '``r``'(:func:`repr`)。如果有提供明" +"確的轉換方式或格式規範,則會覆蓋此預設行為。" #: ../../library/stdtypes.rst:3089 msgid "``printf``-style String Formatting" @@ -5542,6 +5567,8 @@ msgid "" "the given string object. The string must contain two hexadecimal digits per " "byte, with ASCII whitespace being ignored." msgstr "" +"這個 :class:`bytearray` 類別方法會解碼給定的字串物件,並回傳一個 bytearray 物" +"件。該字串每個位元組必須包含兩個十六進位數字,其中的 ASCII 空白字元會被忽略。" #: ../../library/stdtypes.rst:3466 msgid "" @@ -5971,6 +5998,10 @@ msgid "" "removing :meth:`ASCII whitespace `. The *bytes* argument is " "not a prefix; rather, all combinations of its values are stripped::" msgstr "" +"回傳一份序列的複製,並移除指定的開頭位元組。*bytes* 引數是一個二進位序列,用" +"來指定要移除的位元組值的集合。如果省略或為 ``None``,則 *bytes* 引數預設為移" +"除\\ :meth:`ASCII 空白字元 `。*bytes* 引數並非前綴;而是會移除" +"其值的所有組合出現的部分: ::" #: ../../library/stdtypes.rst:3889 msgid "" @@ -6020,6 +6051,11 @@ msgid "" "a separator. Except for splitting from the right, :meth:`rsplit` behaves " "like :meth:`split` which is described in detail below." msgstr "" +"將二進位序列分割為多個相同型別的子序列,並以 *sep* 作為分隔字串。如果有給定 " +"*maxsplit*,則最多進行 *maxsplit* 次分割,且從\\ *最右邊*\\ 開始分割。如果未" +"指定 *sep* 或其為 ``None``,則任何完全由\\ :meth:`ASCII 空白字元 `\\ 組成的子序列都會被視為分隔符。除了從右邊開始分割之外,:meth:" +"`rsplit` 的行為與下方詳述的 :meth:`split` 相同。" #: ../../library/stdtypes.rst:3939 msgid "" @@ -6029,6 +6065,10 @@ msgid "" "removing :meth:`ASCII whitespace `. The *bytes* argument is " "not a suffix; rather, all combinations of its values are stripped::" msgstr "" +"回傳一份序列的複製,並移除指定的結尾位元組。*bytes* 引數是一個二進位序列,用" +"來指定要移除的位元組值的集合。如果省略或為 ``None``,則 *bytes* 引數預設為移" +"除\\ :meth:`ASCII 空白字元 `。*bytes* 引數並非後綴;而是會移除" +"其值的所有組合出現的部分: ::" #: ../../library/stdtypes.rst:3946 msgid "" @@ -6110,6 +6150,10 @@ msgid "" "Consequently, splitting an empty sequence or a sequence consisting solely of " "ASCII whitespace without a specified separator returns ``[]``." msgstr "" +"如果未指定 *sep* 或其為 ``None``,則會套用不同的分割演算法:連續的\\ :meth:" +"`ASCII 空白字元 `\\ 會被視為單一分隔符,並且如果序列開頭或結尾" +"有空白字元,結果中不會包含空字串。因此,在未指定分隔符的情況下分割空序列或僅" +"由 ASCII 空白字元組成的序列,會回傳 ``[]``。" #: ../../library/stdtypes.rst:4006 msgid "" @@ -6136,6 +6180,10 @@ msgid "" "argument is not a prefix or suffix; rather, all combinations of its values " "are stripped::" msgstr "" +"回傳一份序列的複製,並移除指定的開頭和結尾位元組。*bytes* 引數是一個二進位序" +"列,用來指定要移除的位元組值的集合。如果省略或為 ``None``,則 *bytes* 引數預" +"設為移除\\ :meth:`ASCII 空白字元 `。*bytes* 引數並非前綴或後" +"綴;而是會移除其值的所有組合出現的部分: ::" #: ../../library/stdtypes.rst:4025 msgid "" @@ -6526,6 +6574,11 @@ msgid "" "zero or more elements of *values*. The effect is similar to using the :c:" "func:`sprintf` function in the C language." msgstr "" +"Bytes 物件(``bytes``/``bytearray``)具有一個獨有的內建運算:``%`` 運算子(取" +"模)。這也被稱為 bytes 的\\ *格式化*\\ 或\\ *插值*\\ 運算子。給定 ``format % " +"values``\\ (其中 *format* 是一個 bytes 物件),*format* 中的 ``%`` 轉換規範" +"會被替換為零個或多個 *values* 中的元素。這樣的效果類似於在 C 語言中使用 :c:" +"func:`sprintf` 函式。" #: ../../library/stdtypes.rst:4397 msgid "" @@ -6633,6 +6686,8 @@ msgid "" "the nested list representation of the view. If ``view.ndim == 1``, this is " "equal to the number of elements in the view." msgstr "" +"``len(view)`` 等於 :meth:`~memoryview.tolist` 的長度,也就是該檢視巢狀 list " +"表示法的長度。如果 ``view.ndim == 1``,則此值等於該檢視中元素的數量。" #: ../../library/stdtypes.rst:4599 msgid "" @@ -6796,7 +6851,7 @@ msgstr "" #: ../../library/stdtypes.rst:4680 msgid "memoryviews can now be indexed with a tuple of integers." -msgstr "" +msgstr "memoryview 現在可以用整數元組進行索引。" #: ../../library/stdtypes.rst:4683 msgid "memoryview is now a :term:`generic type`." @@ -7454,6 +7509,11 @@ msgid "" "`collections` module.) See :ref:`time-complexity` for the costs of the " "various set operations." msgstr "" +"一個\\ :dfn:`set`\\ (集合)物件是由不重複的\\ :term:`可雜湊 `\\ 物" +"件所組成的無序集合。常見的用途包括成員測試、從序列中移除重複項目,以及計算諸" +"如交集、聯集、差集和對稱差集等數學運算。(若要了解其他容器,請參閱內建的 :" +"class:`dict`、:class:`list` 和 :class:`tuple` 類別,以及 :mod:`collections` " +"模組。)各種集合操作的成本請參閱\\ :ref:`time-complexity`\\ 。" #: ../../library/stdtypes.rst:5093 msgid "" @@ -7719,6 +7779,11 @@ msgid "" "module.) See :ref:`time-complexity` for the costs of the various dictionary " "operations." msgstr "" +"一個\\ :term:`對映 `\\ 物件會將\\ :term:`可雜湊 `\\ 的值對" +"映到任意物件。對映是可變物件。目前只有一種標準的對映型別,也就是\\ :dfn:" +"`dictionary`\\ (字典)。(若要了解其他容器,請參閱內建的 :class:`list`、:" +"class:`set` 和 :class:`tuple` 類別,以及 :mod:`collections` 模組。)各種字典" +"操作的成本請參閱\\ :ref:`time-complexity`\\ 。" #: ../../library/stdtypes.rst:5318 msgid "" @@ -8599,6 +8664,8 @@ msgid "" "Instances of ``GenericAlias`` are not classes at runtime, even though they " "behave like classes (they can be instantiated and subclassed)::" msgstr "" +"``GenericAlias`` 的實例在執行期並不是類別,儘管它們的行為與類別相似(它們可以" +"被實例化及子類別化): ::" #: ../../library/stdtypes.rst:5895 msgid "" @@ -8606,11 +8673,14 @@ msgid "" ">>> inspect.isclass(list[int])\n" "False" msgstr "" +">>> import inspect\n" +">>> inspect.isclass(list[int])\n" +"False" #: ../../library/stdtypes.rst:5899 msgid "" "This is true for :ref:`user-defined generics ` also." -msgstr "這對\\ :ref:`使用者定義泛型 `\\ 也是成立的。" +msgstr "這對\\ :ref:`使用者定義泛型 `\\ 同樣適用。" #: ../../library/stdtypes.rst:5901 msgid "" @@ -9058,7 +9128,6 @@ msgstr "" " return number ** 2" #: ../../library/stdtypes.rst:6084 -#, fuzzy msgid "" "The ``|`` operator cannot be used at runtime to define unions where one or " "more members is a forward reference. For example, ``int | \"Foo\"``, where " @@ -9066,10 +9135,10 @@ msgid "" "For unions which include forward references, present the whole expression as " "a string, e.g. ``\"int | Foo\"``." msgstr "" -"不能在 runtime 使用 ``|`` 運算元 (operand) 來定義有一個以上的成員為向前參照 " -"(forward reference) 的聯合。例如 ``int | \"Foo\"``,其中 ``\"Foo\"`` 是對未定" -"義類別的參照,將在 runtime 失敗。對於包含向前參照的聯合,請將整個運算式以字串" -"呈現,例如 ``\"int | Foo\"``。" +"``|`` 運算子不能在 runtime 用來定義有一個以上的成員為向前參照 (forward " +"reference) 的聯合。例如 ``int | \"Foo\"``,其中 ``\"Foo\"`` 是對尚未定義的類" +"別的參照,將在 runtime 失敗。對於包含向前參照的聯合,請將整個運算式以字串呈" +"現,例如 ``\"int | Foo\"``。" #: ../../library/stdtypes.rst:6092 msgid "" @@ -9307,6 +9376,9 @@ msgid "" "`~list.append` on lists) and :ref:`class instance methods `. Built-in methods are described with the types that support them." msgstr "" +"方法是使用屬性表示法呼叫的函式,有兩種類型:\\ :ref:`內建方法 `\\ (例如 list 上的 :meth:`~list.append`\\ )和\\ :ref:`類別實例方" +"法 `。內建方法會與支援它們的型別一起說明。" #: ../../library/stdtypes.rst:6246 msgid "" diff --git a/library/string.po b/library/string.po index 6d60b12a8b..166729fcd7 100644 --- a/library/string.po +++ b/library/string.po @@ -1529,6 +1529,9 @@ msgid "" "object, with four named capturing groups. The capturing groups correspond " "to the rules given above, along with the invalid placeholder rule:" msgstr "" +"或者,你也可以透過覆寫類別屬性 *pattern* 來提供整個正規表示式模式。如果這麼" +"做,該值必須是一個正規表示式模式字串,或是一個已編譯的正規表示式物件,並帶有" +"四個具名擷取群組。這些擷取群組對應於上述規則,以及無效佔位符號規則:" #: ../../library/string.rst:979 msgid "" diff --git a/library/struct.po b/library/struct.po index 1738caa729..9cddbc4a5c 100644 --- a/library/struct.po +++ b/library/struct.po @@ -98,7 +98,6 @@ msgstr "" "數必須完全符合格式所需的數值。" #: ../../library/struct.rst:68 -#, fuzzy msgid "" "Pack the values *v1*, *v2*, ... according to the format string *format* and " "write the packed bytes into the writable buffer *buffer* starting at " @@ -106,7 +105,8 @@ msgid "" "*offset* counts from the end of *buffer*." msgstr "" "依照格式字串 *format* 打包數值 *v1*、*v2*、...,並將打包後的位元組寫入可寫緩" -"衝區 *buffer* 中從位置 *offset* 開始的地方。請注意 *offset* 是必要的引數。" +"衝區 *buffer* 中從位置 *offset* 開始的地方。請注意 *offset* 是必要的引數。若 " +"*offset* 為負數,則從 *buffer* 的結尾開始計算。" #: ../../library/struct.rst:76 msgid "" @@ -120,7 +120,6 @@ msgstr "" "格式所需的大小,如 :func:`calcsize` 所示。" #: ../../library/struct.rst:84 -#, fuzzy msgid "" "Unpack from *buffer* starting at position *offset*, according to the format " "string *format*. The result is a tuple even if it contains exactly one " @@ -130,7 +129,8 @@ msgid "" msgstr "" "根據格式字串 *format* 從 *buffer* 的 *offset* 位置開始解包。即使它只包含一個" "項目,結果也都是一個元組。緩衝區從位置 *offset* 開始的位元組大小,必須至少達" -"到格式所需的大小,如 :func:`calcsize` 所示。" +"到格式所需的大小,如 :func:`calcsize` 所示。若 *offset* 為負數,則從 " +"*buffer* 的結尾開始計算。" #: ../../library/struct.rst:93 msgid "" diff --git a/library/subprocess.po b/library/subprocess.po index d39000874c..acc627179c 100644 --- a/library/subprocess.po +++ b/library/subprocess.po @@ -323,6 +323,8 @@ msgid "" "Exit status of the child process, an integer. If the process exited due to " "a signal, this will be the negative signal number." msgstr "" +"子行程的結束狀態,為一個整數。如果該行程因訊號而結束,則此值會是該訊號編號的" +"負數。" #: ../../library/subprocess.rst:251 msgid "" diff --git a/library/sys.monitoring.po b/library/sys.monitoring.po index d08aa8a3e6..37d579c6d0 100644 --- a/library/sys.monitoring.po +++ b/library/sys.monitoring.po @@ -115,6 +115,8 @@ msgid "" "would not disable global or local events associated with *tool_id*, nor " "unregister any callback functions." msgstr "" +"現在會在釋放 *tool_id* 之前呼叫 :func:`clear_tool_id`。先前,它不會停用與 " +"*tool_id* 相關聯的全域或區域事件,也不會取消註冊任何回呼函式。" #: ../../library/sys.monitoring.rst:71 msgid "" diff --git a/library/sys.po b/library/sys.po index 93bf828ce6..dc6b94d7a9 100644 --- a/library/sys.po +++ b/library/sys.po @@ -2308,6 +2308,11 @@ msgid "" "Per-line events may be disabled for a frame by setting :attr:`~frame." "f_trace_lines` to :const:`False` on that :ref:`frame `." msgstr "" +"直譯器即將執行新的一行程式碼,或重新執行迴圈的條件。此時會呼叫區域追蹤函式;" +"*arg* 為 ``None``;回傳值指定新的區域追蹤函式。詳細說明請參閱 :source:" +"`InternalDocs/code_objects.md`。可以透過在該 :ref:`frame ` 上" +"將 :attr:`~frame.f_trace_lines` 設為 :const:`False`,來停用該 frame 的逐行事" +"件。" #: ../../library/sys.rst:1808 msgid "" @@ -2589,6 +2594,8 @@ msgid "" "The encoding and error handling are initialized from :c:member:`PyConfig." "stdio_encoding` and :c:member:`PyConfig.stdio_errors`." msgstr "" +"編碼和錯誤處理會依據 :c:member:`PyConfig.stdio_encoding` 和 :c:member:" +"`PyConfig.stdio_errors` 初始化。" #: ../../library/sys.rst:2023 msgid "" diff --git a/library/tarfile.po b/library/tarfile.po index b4e4ebbdaf..cfae100649 100644 --- a/library/tarfile.po +++ b/library/tarfile.po @@ -1131,7 +1131,6 @@ msgstr "" "func:`data ` 篩選器。" #: ../../library/tarfile.rst:660 -#, fuzzy msgid "" "The attribute may be set on instances or overridden in subclasses. It also " "is possible to set it on the ``TarFile`` class itself to set a global " @@ -1141,9 +1140,9 @@ msgid "" "wrapped in :deco:`staticmethod` to prevent injection of a ``self`` argument." msgstr "" "此屬性可以在實例上設定或在子類別中覆寫。也可以在 ``TarFile`` 類別本身上設定它" -"以設定全域預設值,儘管由於它會影響 *tarfile* 的所有使用,最佳做法是僅在頂層應" +"以建立全域預設值,儘管由於它會影響 *tarfile* 的所有使用,最佳做法是僅在頂層應" "用程式或 :mod:`site 組態 `\\ 中這樣做。要以這種方式設定全域預設值,需要" -"將篩選器函式包裝在 :func:`staticmethod` 中以防止注入 ``self`` 引數。" +"將篩選器函式包裝在 :deco:`staticmethod` 中以防止注入 ``self`` 引數。" #: ../../library/tarfile.rst:670 msgid "" @@ -1678,16 +1677,15 @@ msgstr "" "class:`~tarfile.AbsolutePathError`。" #: ../../library/tarfile.rst:1103 -#, fuzzy msgid "" "Normalize filenames (:attr:`TarInfo.name`) that contain ``..`` components " "using :func:`os.path.normpath`. Note that this removes internal ``..`` " "components, which may change the meaning of the name if it traverses " "symbolic links." msgstr "" -"使用 :func:`os.path.normpath` 正規化連結目標(:attr:`TarInfo.linkname`)。請" -"注意,這會移除內部的 ``..`` 元件,如果 :attr:`!TarInfo.linkname` 中的路徑會遍" -"歷符號連結,這可能會改變連結的意義。" +"使用 :func:`os.path.normpath` 正規化包含 ``..`` 元件的檔名(:attr:`TarInfo." +"name`)。請注意,這會移除內部的 ``..`` 元件,如果該名稱中的路徑會遍歷符號連" +"結,這可能會改變名稱的意義。" #: ../../library/tarfile.rst:1107 msgid "" @@ -1712,9 +1710,8 @@ msgid "Return the modified ``TarInfo`` member." msgstr "回傳修改後的 ``TarInfo`` 成員。" #: ../../library/tarfile.rst:1117 -#, fuzzy msgid "Filenames containing ``..`` components are now normalized." -msgstr "連結目標現在會被正規化。" +msgstr "包含 ``..`` 元件的檔名現在會被正規化。" #: ../../library/tarfile.rst:1121 msgid "" diff --git a/library/tempfile.po b/library/tempfile.po index 5051612333..b7646a3fc8 100644 --- a/library/tempfile.po +++ b/library/tempfile.po @@ -425,14 +425,14 @@ msgid "" msgstr "檔案描述器\\ :ref:`不會被子行程繼承 `。" #: ../../library/tempfile.rst:232 -#, fuzzy msgid "" "Unlike :func:`TemporaryFile`, the user of :func:`mkstemp` is responsible for " "closing the file descriptor (for example, using :func:`os.close`) and " "deleting the temporary file (for example, using :func:`os.remove`)." msgstr "" -"與 :func:`TemporaryFile` 不同,:func:`mkstemp` 使用者用完臨時檔案後需要自行將" -"其刪除。" +"與 :func:`TemporaryFile` 不同,:func:`mkstemp` 的使用者需要自行負責關閉檔案描" +"述器(例如使用 :func:`os.close`)並刪除該臨時檔案(例如使用 :func:`os." +"remove`)。" #: ../../library/tempfile.rst:236 msgid "" @@ -578,14 +578,14 @@ msgid "A platform-specific location:" msgstr "與平臺相關的位置:" #: ../../library/tempfile.rst:324 -#, fuzzy msgid "" "On Windows, the directories :file:`%USERPROFILE%\\\\AppData\\\\Local\\" "\\Temp`, :file:`%SYSTEMROOT%\\\\Temp`, :file:`C:\\\\TEMP`, :file:`C:\\" "\\TMP`, :file:`\\\\TEMP`, and :file:`\\\\TMP`, in that order." msgstr "" -"在 Windows 上,目錄依次為 :file:`C:\\\\TEMP`、:file:`C:\\\\TMP`、:file:`\\" -"\\TEMP` 和 :file:`\\\\TMP`。" +"在 Windows 上,目錄依次為 :file:`%USERPROFILE%\\\\AppData\\\\Local\\" +"\\Temp`、:file:`%SYSTEMROOT%\\\\Temp`、:file:`C:\\\\TEMP`、:file:`C:\\" +"\\TMP`、:file:`\\\\TEMP` 和 :file:`\\\\TMP`。" #: ../../library/tempfile.rst:330 msgid "" diff --git a/library/test.po b/library/test.po index a01273f8d3..505f65adf9 100644 --- a/library/test.po +++ b/library/test.po @@ -390,9 +390,8 @@ msgid "" msgstr "" #: ../../library/test.rst:290 -#, fuzzy msgid "Its default value is 10 seconds." -msgstr "預設值為 30 秒。" +msgstr "預設值為 10 秒。" #: ../../library/test.rst:292 msgid "See also :data:`INTERNET_TIMEOUT`." @@ -918,6 +917,8 @@ msgid "" "expectedFailure`. Any use of this decorator should have an associated " "comment identifying the relevant tracker issue." msgstr "" +"一個用於有條件地以 :deco:`unittest.expectedFailure` 標記測試的裝飾器。使用此" +"裝飾器時應附上識別相關追蹤器議題的註解。" #: ../../library/test.rst:729 msgid "" @@ -1181,6 +1182,12 @@ msgid "" "failure or error shows the original subprocess traceback as the cause of the " "exception." msgstr "" +"一個裝飾器,會在一個全新的直譯器子行程中以隔離的方式執行被裝飾的測試,因此它" +"不會與測試執行的其餘部分共享全域或直譯器狀態。它可以裝飾一個測試方法,也可以" +"裝飾整個 :class:`~unittest.TestCase` 子類別。被裝飾的方法不得接受額外的引數。" +"子行程中的失敗、錯誤或跳過會回報給對應的測試,個別失敗或被跳過的\\ :meth:`子" +"測試 ` 也會被個別回報。被回報的失敗或錯誤會將原始" +"子行程的追蹤回溯顯示為該例外的成因。" #: ../../library/test.rst:980 msgid "" @@ -1190,6 +1197,11 @@ msgid "" "tearDownClass` and ``setUpModule()`` / ``tearDownModule()``) run both in the " "parent process (as usual) and in the subprocess around the method." msgstr "" +"當裝飾的對象是**方法**時,只有該方法會在子行程中執行;所有 fixture(:meth:" +"`~unittest.TestCase.setUp`\\ / :meth:`~unittest.TestCase.tearDown`、:meth:" +"`~unittest.TestCase.setUpClass`\\ / :meth:`~unittest.TestCase.tearDownClass` " +"以及 ``setUpModule()``\\ / ``tearDownModule()``)都會如常在父行程中執行一次," +"並在子行程中圍繞該方法再執行一次。" #: ../../library/test.rst:986 msgid "" @@ -1202,6 +1214,13 @@ msgid "" "be controlled by a class decorator, so it still runs in the parent process " "too; test it with :data:`runningInSubprocess` if needed." msgstr "" +"當裝飾的對象是**類別**時,整個類別會在單一子行程中執行,且 :meth:`~unittest." +"TestCase.setUpClass`、:meth:`~unittest.TestCase.tearDownClass`、:meth:" +"`~unittest.TestCase.setUp` 和 :meth:`~unittest.TestCase.tearDown` 都只會在子" +"行程中各執行一次,並在父行程中被跳過。子行程中 :meth:`~unittest.TestCase." +"setUpClass` 的失敗或跳過會回報給整個類別。``setUpModule()`` 無法由類別裝飾器" +"控制,因此它仍然也會在父行程中執行;如有需要,可以用 :data:" +"`runningInSubprocess` 來檢測。" #: ../../library/test.rst:996 msgid "" @@ -1210,6 +1229,10 @@ msgid "" "support.requires_resource`, :func:`~test.support.requires`, :func:`~test." "support.bigmemtest` and the like behave consistently in both processes." msgstr "" +"子行程會繼承父測試執行的已啟用資源(``-u``)、記憶體限制(``-M``)和詳細程度" +"(``-v``),因此 :func:`~test.support.requires_resource`、:func:`~test." +"support.requires`、:func:`~test.support.bigmemtest` 等函式在兩個行程中的行為" +"會保持一致。" #: ../../library/test.rst:1002 msgid "" @@ -1219,6 +1242,10 @@ msgid "" "the variable. Note that :option:`-E` and :option:`-I` make the subprocess " "ignore the ``PYTHON*`` environment variables, including :envvar:`PYTHONPATH`." msgstr "" +"*options* 是用來執行子行程的直譯器命令列選項序列,*env* 則是要在繼承的環境之" +"上、於子行程中設定的環境變數對映。若 *env* 中某個值為 ``None``,則會取消設定" +"該變數。請注意,:option:`-E` 和 :option:`-I` 會讓子行程忽略 ``PYTHON*`` 環境" +"變數,包括 :envvar:`PYTHONPATH`。" #: ../../library/test.rst:1010 msgid "" @@ -1226,10 +1253,13 @@ msgid "" "reported as an error if it does not complete in time. By default there is no " "timeout, and a hung test is left to the timeout of the test runner." msgstr "" +"*timeout* 是等待子行程的秒數;如果測試未能在時限內完成,則會被回報為錯誤。預" +"設情況下沒有逾時限制,卡住的測試會交由 test runner(測試執行器)的逾時機制處" +"理。" #: ../../library/test.rst:1015 msgid "The test is skipped on platforms without subprocess support." -msgstr "" +msgstr "在不支援子行程的平台上,該測試會被跳過。" #: ../../library/test.rst:1020 msgid "" @@ -1241,6 +1271,12 @@ msgid "" "``setUpModule()`` and ``tearDownModule()`` can test it to choose which code " "to run in the subprocess." msgstr "" +"當程式碼在由 :func:`runInSubprocess` 衍生的隔離子行程中執行時為 ``True``,否" +"則為 ``False``\\ (包括在父行程中,以及在一般、非隔離的測試執行中)。像 :" +"meth:`~unittest.TestCase.setUp`、:meth:`~unittest.TestCase.tearDown`、:meth:" +"`~unittest.TestCase.setUpClass`、:meth:`~unittest.TestCase.tearDownClass`、" +"``setUpModule()`` 和 ``tearDownModule()`` 這樣的 fixture 可以檢測它,以選擇要" +"在子行程中執行哪些程式碼。" #: ../../library/test.rst:1034 msgid "Assert instances of *cls* are deallocated after iterating." diff --git a/library/time-complexity.po b/library/time-complexity.po index f10f960e3c..7193de9911 100644 --- a/library/time-complexity.po +++ b/library/time-complexity.po @@ -19,7 +19,7 @@ msgstr "" #: ../../library/time-complexity.rst:5 msgid "Time complexity of operations on built-in types" -msgstr "" +msgstr "內建型別操作的時間複雜度" #: ../../library/time-complexity.rst:7 msgid "" @@ -28,6 +28,9 @@ msgid "" "performance characteristics. Additionally, the listed costs assume exact " "built-in types, as instances of subclasses may have different costs." msgstr "" +"本頁記錄了 CPython 中各種內建型別操作的時間複雜度。其他 Python 實作可能有不同" +"的效能特性。此外,所列出的成本皆假設為確切的內建型別,因為子類別的實例可能有" +"不同的成本。" #: ../../library/time-complexity.rst:12 msgid "" @@ -36,10 +39,13 @@ msgid "" "number of elements currently in the container, and *k* is the value of a " "numeric parameter, such as an index or a repeat count." msgstr "" +"我們使用 |big O notation|_ 來描述一項操作的執行時間如何隨著輸入大小而成長。除" +"非另有說明,*n* 代表容器中目前的元素數量,*k* 則代表數值參數的值,例如索引或" +"重複次數。" #: ../../library/time-complexity.rst:22 msgid ":class:`!list`" -msgstr "" +msgstr ":class:`!list`" #: ../../library/time-complexity.rst:24 msgid "" @@ -50,24 +56,28 @@ msgid "" "move). If you need to add or remove at both ends, consider using a :class:" "`collections.deque` instead." msgstr "" +"list 是可變的序列;如需更多實作細節,請參閱\\ :ref:`how-are-lists-" +"implemented`\\ 。最大的成本來自於成長超出目前配置的大小(因為所有元素都必須搬" +"移),或是在接近開頭處插入或刪除元素(因為之後的所有元素都必須搬移)。如果你" +"需要在兩端新增或移除元素,可以考慮改用 :class:`collections.deque`\\ 。" #: ../../library/time-complexity.rst:34 ../../library/time-complexity.rst:85 #: ../../library/time-complexity.rst:121 ../../library/time-complexity.rst:156 #: ../../library/time-complexity.rst:199 ../../library/time-complexity.rst:232 #: ../../library/time-complexity.rst:259 msgid "Operation" -msgstr "" +msgstr "操作" #: ../../library/time-complexity.rst:35 ../../library/time-complexity.rst:86 #: ../../library/time-complexity.rst:122 ../../library/time-complexity.rst:157 #: ../../library/time-complexity.rst:200 ../../library/time-complexity.rst:233 #: ../../library/time-complexity.rst:260 msgid "Complexity" -msgstr "" +msgstr "複雜度" #: ../../library/time-complexity.rst:36 msgid "Copy (``l.copy()``)" -msgstr "" +msgstr "複製(``l.copy()``)" #: ../../library/time-complexity.rst:37 ../../library/time-complexity.rst:51 #: ../../library/time-complexity.rst:68 ../../library/time-complexity.rst:70 @@ -79,11 +89,11 @@ msgstr "" #: ../../library/time-complexity.rst:243 ../../library/time-complexity.rst:245 #: ../../library/time-complexity.rst:270 ../../library/time-complexity.rst:272 msgid "*O*\\ (*n*)" -msgstr "" +msgstr "*O*\\ (*n*)" #: ../../library/time-complexity.rst:38 msgid "Append (``l.append(x)``) [1]_" -msgstr "" +msgstr "附加(``l.append(x)``) [1]_" #: ../../library/time-complexity.rst:39 ../../library/time-complexity.rst:45 #: ../../library/time-complexity.rst:47 ../../library/time-complexity.rst:72 @@ -100,113 +110,115 @@ msgstr "" #: ../../library/time-complexity.rst:266 ../../library/time-complexity.rst:268 #: ../../library/time-complexity.rst:274 msgid "*O*\\ (1)" -msgstr "" +msgstr "*O*\\ (1)" #: ../../library/time-complexity.rst:40 msgid "Pop (``l.pop(k)``) [1]_ [2]_" -msgstr "" +msgstr "彈出(``l.pop(k)``) [1]_ [2]_" #: ../../library/time-complexity.rst:41 ../../library/time-complexity.rst:43 #: ../../library/time-complexity.rst:49 msgid "*O*\\ (*n* - *k*)" -msgstr "" +msgstr "*O*\\ (*n* - *k*)" #: ../../library/time-complexity.rst:42 msgid "Insert (``l.insert(k, x)``) [1]_ [2]_" -msgstr "" +msgstr "插入(``l.insert(k, x)``) [1]_ [2]_" #: ../../library/time-complexity.rst:44 msgid "Get item (``l[k]``)" -msgstr "" +msgstr "取得項目(``l[k]``)" #: ../../library/time-complexity.rst:46 msgid "Set item (``l[k] = x``)" -msgstr "" +msgstr "設定項目(``l[k] = x``)" #: ../../library/time-complexity.rst:48 msgid "Delete item (``del l[k]``) [2]_" -msgstr "" +msgstr "刪除項目(``del l[k]``) [2]_" #: ../../library/time-complexity.rst:50 ../../library/time-complexity.rst:97 #: ../../library/time-complexity.rst:215 ../../library/time-complexity.rst:269 msgid "Iteration" -msgstr "" +msgstr "疊代" #: ../../library/time-complexity.rst:52 msgid "Get slice (``l[i:j]``)" -msgstr "" +msgstr "取得切片(``l[i:j]``)" #: ../../library/time-complexity.rst:53 ../../library/time-complexity.rst:92 #: ../../library/time-complexity.rst:204 msgid "*O*\\ (*j* - *i*)" -msgstr "" +msgstr "*O*\\ (*j* - *i*)" #: ../../library/time-complexity.rst:54 msgid "Set slice (``l[i:j] = t``) [1]_" -msgstr "" +msgstr "設定切片(``l[i:j] = t``) [1]_" #: ../../library/time-complexity.rst:55 msgid "" "*O*\\ (*j* - *i*) if len(*t*) == *j* - *i*, otherwise *O*\\ (*n* - *i* + " "len(*t*))" msgstr "" +"當 len(*t*) 等於 *j* - *i* 時為 *O*\\ (*j* - *i*),否則為 *O*\\ (*n* - *i* + " +"len(*t*))" #: ../../library/time-complexity.rst:57 msgid "Delete slice (``del l[i:j]``)" -msgstr "" +msgstr "刪除切片(``del l[i:j]``)" #: ../../library/time-complexity.rst:58 msgid "*O*\\ (*n* - *i*)" -msgstr "" +msgstr "*O*\\ (*n* - *i*)" #: ../../library/time-complexity.rst:59 msgid "Extend (``l.extend(t)``) [1]_ [3]_" -msgstr "" +msgstr "擴充(``l.extend(t)``) [1]_ [3]_" #: ../../library/time-complexity.rst:60 ../../library/time-complexity.rst:134 msgid "*O*\\ (len(*t*))" -msgstr "" +msgstr "*O*\\ (len(*t*))" #: ../../library/time-complexity.rst:61 msgid "Sort (``l.sort()``) [4]_" -msgstr "" +msgstr "排序(``l.sort()``) [4]_" #: ../../library/time-complexity.rst:62 msgid "*O*\\ (*n* log *n*)" -msgstr "" +msgstr "*O*\\ (*n* log *n*)" #: ../../library/time-complexity.rst:63 msgid "Concatenate (``l1 + l2``)" -msgstr "" +msgstr "連接(``l1 + l2``)" #: ../../library/time-complexity.rst:64 msgid "*O*\\ (len(*l1*) + len(*l2*))" -msgstr "" +msgstr "*O*\\ (len(*l1*) + len(*l2*))" #: ../../library/time-complexity.rst:65 msgid "Multiply (``l * k``)" -msgstr "" +msgstr "乘法(``l * k``)" #: ../../library/time-complexity.rst:66 ../../library/time-complexity.rst:96 #: ../../library/time-complexity.rst:208 msgid "*O*\\ (*nk*)" -msgstr "" +msgstr "*O*\\ (*nk*)" #: ../../library/time-complexity.rst:67 msgid "``x in l``" -msgstr "" +msgstr "``x in l``" #: ../../library/time-complexity.rst:69 msgid "``min(l)``, ``max(l)``" -msgstr "" +msgstr "``min(l)``, ``max(l)``" #: ../../library/time-complexity.rst:71 msgid "Get length (``len(l)``) [5]_" -msgstr "" +msgstr "取得長度(``len(l)``) [5]_" #: ../../library/time-complexity.rst:76 msgid ":class:`!tuple`" -msgstr "" +msgstr ":class:`!tuple`" #: ../../library/time-complexity.rst:78 msgid "" @@ -214,46 +226,49 @@ msgid "" "change, there are no insertion or deletion costs, and making a copy simply " "returns the same object, so is constant time (*O*\\ (1))." msgstr "" +":class:`tuple` 是一個 :term:`immutable`\\ (不可變的)序列。因為 tuple 永遠不" +"會改變,所以沒有插入或刪除的成本,而複製只會回傳同一個物件,因此是常數時間" +"(*O*\\ (1))。" #: ../../library/time-complexity.rst:87 msgid "Copy (``tuple(t)``)" -msgstr "" +msgstr "複製(``tuple(t)``)" #: ../../library/time-complexity.rst:89 msgid "Get item (``t[k]``)" -msgstr "" +msgstr "取得項目(``t[k]``)" #: ../../library/time-complexity.rst:91 msgid "Get slice (``t[i:j]``)" -msgstr "" +msgstr "取得切片(``t[i:j]``)" #: ../../library/time-complexity.rst:93 msgid "Concatenate (``t1 + t2``)" -msgstr "" +msgstr "連接(``t1 + t2``)" #: ../../library/time-complexity.rst:94 msgid "*O*\\ (len(*t1*) + len(*t2*))" -msgstr "" +msgstr "*O*\\ (len(*t1*) + len(*t2*))" #: ../../library/time-complexity.rst:95 msgid "Multiply (``t * k``)" -msgstr "" +msgstr "乘法(``t * k``)" #: ../../library/time-complexity.rst:99 msgid "``x in t``" -msgstr "" +msgstr "``x in t``" #: ../../library/time-complexity.rst:101 msgid "``min(t)``, ``max(t)``" -msgstr "" +msgstr "``min(t)``, ``max(t)``" #: ../../library/time-complexity.rst:103 msgid "Get length (``len(t)``) [5]_" -msgstr "" +msgstr "取得長度(``len(t)``) [5]_" #: ../../library/time-complexity.rst:108 msgid ":class:`!dict`" -msgstr "" +msgstr ":class:`!dict`" #: ../../library/time-complexity.rst:110 msgid "" @@ -265,42 +280,47 @@ msgid "" "also assume that hashing and comparing a key is *O*\\ (1). For more detail " "on the implementation, see :ref:`how-are-dictionaries-implemented`." msgstr "" +"針對 dict 物件所列出的時間為平均情況下的時間,因為這些數字假設物件的雜湊函式" +"足夠穩健,使碰撞情況不常發生。它們也假設鍵在所有可能鍵值的集合中分佈均勻。在" +"最壞情況下,當所有鍵都雜湊到相同的值時,以下每個 *O*\\ (1) 的操作反而會花費 " +"*O*\\ (*n*) 的時間。它們也假設雜湊和比較一個鍵的成本是 *O*\\ (1)。如需更多實" +"作細節,請參閱\\ :ref:`how-are-dictionaries-implemented`\\ 。" #: ../../library/time-complexity.rst:123 msgid "``key in d``" -msgstr "" +msgstr "``key in d``" #: ../../library/time-complexity.rst:125 msgid "Copy (``d.copy()``) [7]_" -msgstr "" +msgstr "複製(``d.copy()``) [7]_" #: ../../library/time-complexity.rst:127 msgid "Get item (``d[key]``, ``d.get(key)``)" -msgstr "" +msgstr "取得項目(``d[key]``、``d.get(key)``)" #: ../../library/time-complexity.rst:129 msgid "Set item (``d[key] = value``) [1]_" -msgstr "" +msgstr "設定項目(``d[key] = value``) [1]_" #: ../../library/time-complexity.rst:131 msgid "Delete item (``del d[key]``, ``d.pop(key)``)" -msgstr "" +msgstr "刪除項目(``del d[key]``、``d.pop(key)``)" #: ../../library/time-complexity.rst:133 msgid "Update (``d.update(t)``, ``d |= t``) [1]_ [3]_ [7]_" -msgstr "" +msgstr "更新(``d.update(t)``、``d |= t``) [1]_ [3]_ [7]_" #: ../../library/time-complexity.rst:135 msgid "Iteration [7]_" -msgstr "" +msgstr "疊代 [7]_" #: ../../library/time-complexity.rst:137 msgid "Get length (``len(d)``) [5]_" -msgstr "" +msgstr "取得長度(``len(d)``) [5]_" #: ../../library/time-complexity.rst:142 msgid ":class:`!set`, :class:`!frozenset`" -msgstr "" +msgstr ":class:`!set`、:class:`!frozenset`" #: ../../library/time-complexity.rst:144 msgid "" @@ -309,6 +329,9 @@ msgid "" "operations instead take *O*\\ (*n*) time, and operations that look up every " "element degrade accordingly." msgstr "" +"請參閱 :class:`dict`\\ ,因為 :class:`set` 和 :class:`frozenset` 的實作方式相" +"似,相同的注意事項也同樣適用。在最壞情況下,*O*\\ (1) 的操作反而需要花費 " +"*O*\\ (*n*) 的時間,而查找每個元素的操作也會相應地變差。" #: ../../library/time-complexity.rst:149 msgid "" @@ -316,85 +339,90 @@ msgid "" "discarding, or the in-place update operations. The others below apply to it " "at the same costs." msgstr "" +":class:`frozenset` 是 :term:`immutable`\\ (不可變的),因此不支援新增、捨棄" +"或原地更新操作。以下其他操作則以相同的成本適用於它。" #: ../../library/time-complexity.rst:158 msgid "``x in s``" -msgstr "" +msgstr "``x in s``" #: ../../library/time-complexity.rst:160 msgid "Copy (``s.copy()``) [6]_ [7]_" -msgstr "" +msgstr "複製(``s.copy()``) [6]_ [7]_" #: ../../library/time-complexity.rst:162 msgid "Add (``s.add(x)``) [1]_" -msgstr "" +msgstr "新增(``s.add(x)``) [1]_" #: ../../library/time-complexity.rst:164 msgid "Discard (``s.discard(x)``, ``s.remove(x)``)" -msgstr "" +msgstr "捨棄(``s.discard(x)``、``s.remove(x)``)" #: ../../library/time-complexity.rst:166 msgid "Union (``s1 | s2``, ``s1.union(s2)``) [7]_" -msgstr "" +msgstr "聯集(``s1 | s2``、``s1.union(s2)``) [7]_" #: ../../library/time-complexity.rst:167 ../../library/time-complexity.rst:179 msgid "*O*\\ (len(*s1*) + len(*s2*))" -msgstr "" +msgstr "*O*\\ (len(*s1*) + len(*s2*))" #: ../../library/time-complexity.rst:168 msgid "Update (``s1 |= s2``, ``s1.update(s2)``) [1]_ [7]_" -msgstr "" +msgstr "更新(``s1 |= s2``、``s1.update(s2)``) [1]_ [7]_" #: ../../library/time-complexity.rst:169 ../../library/time-complexity.rst:181 msgid "*O*\\ (len(*s2*))" -msgstr "" +msgstr "*O*\\ (len(*s2*))" #: ../../library/time-complexity.rst:170 msgid "Intersection (``s1 & s2``, ``s1.intersection(s2)``) [7]_ [8]_" -msgstr "" +msgstr "交集(``s1 & s2``、``s1.intersection(s2)``) [7]_ [8]_" #: ../../library/time-complexity.rst:171 ../../library/time-complexity.rst:173 #: ../../library/time-complexity.rst:177 msgid "*O*\\ (min(len(*s1*), len(*s2*)))" -msgstr "" +msgstr "*O*\\ (min(len(*s1*), len(*s2*)))" #: ../../library/time-complexity.rst:172 msgid "" "Intersection update (``s1 &= s2``, ``s1.intersection_update(s2)``) [1]_ [7]_ " "[8]_" msgstr "" +"交集更新(``s1 &= s2``、``s1.intersection_update(s2)``) [1]_ [7]_ [8]_" #: ../../library/time-complexity.rst:174 msgid "Difference (``s1 - s2``, ``s1.difference(s2)``) [7]_ [9]_" -msgstr "" +msgstr "差集(``s1 - s2``、``s1.difference(s2)``) [7]_ [9]_" #: ../../library/time-complexity.rst:175 msgid "*O*\\ (len(*s1*))" -msgstr "" +msgstr "*O*\\ (len(*s1*))" #: ../../library/time-complexity.rst:176 msgid "" "Difference update (``s1 -= s2``, ``s1.difference_update(s2)``) [1]_ [7]_ [8]_" -msgstr "" +msgstr "差集更新(``s1 -= s2``、``s1.difference_update(s2)``) [1]_ [7]_ [8]_" #: ../../library/time-complexity.rst:178 msgid "" "Symmetric difference (``s1 ^ s2``, ``s1.symmetric_difference(s2)``) [7]_" -msgstr "" +msgstr "對稱差集(``s1 ^ s2``、``s1.symmetric_difference(s2)``) [7]_" #: ../../library/time-complexity.rst:180 msgid "" "Symmetric difference update (``s1 ^= s2``, ``s1." "symmetric_difference_update(s2)``) [1]_ [7]_" msgstr "" +"對稱差集更新(``s1 ^= s2``、``s1.symmetric_difference_update(s2)``) [1]_ " +"[7]_" #: ../../library/time-complexity.rst:182 ../../library/time-complexity.rst:217 msgid "Get length (``len(s)``) [5]_" -msgstr "" +msgstr "取得長度(``len(s)``) [5]_" #: ../../library/time-complexity.rst:187 msgid ":class:`!str`, :class:`!bytes`, :class:`!bytearray`" -msgstr "" +msgstr ":class:`!str`、:class:`!bytes`、:class:`!bytearray`" #: ../../library/time-complexity.rst:189 msgid "" @@ -406,46 +434,51 @@ msgid "" "k]``) only advances the start of the buffer instead of moving the remaining " "bytes, and is amortized *O*\\ (1)." msgstr "" +":class:`str` 和 :class:`bytes` 物件分別是字元和位元組的不可變序列。和 tuple " +"一樣,複製它們會回傳原始物件。:class:`bytearray` 是可變的,並額外支援 :class:" +"`list` 的可變操作(:meth:`!sort` 除外),且成本相同。不過,使用 ``del``\\ " +"(``del b[0]``、``del b[:k]``)在開頭刪除時,只會推進緩衝區的起始位置,而不會" +"搬移剩餘的位元組,因此是攤銷 *O*\\ (1)。" #: ../../library/time-complexity.rst:201 msgid "Get item (``s[k]``)" -msgstr "" +msgstr "取得項目(``s[k]``)" #: ../../library/time-complexity.rst:203 msgid "Get slice (``s[i:j]``)" -msgstr "" +msgstr "取得切片(``s[i:j]``)" #: ../../library/time-complexity.rst:205 msgid "Concatenate (``s + t``) [10]_" -msgstr "" +msgstr "連接(``s + t``) [10]_" #: ../../library/time-complexity.rst:206 msgid "*O*\\ (len(*s*) + len(*t*))" -msgstr "" +msgstr "*O*\\ (len(*s*) + len(*t*))" #: ../../library/time-complexity.rst:207 msgid "Multiply (``s * k``)" -msgstr "" +msgstr "乘法(``s * k``)" #: ../../library/time-complexity.rst:209 msgid "Substring search (``x in s``, ``s.find(x)``, ``s.index(x)``) [11]_" -msgstr "" +msgstr "子字串搜尋(``x in s``、``s.find(x)``、``s.index(x)``) [11]_" #: ../../library/time-complexity.rst:211 msgid "Reverse substring search (``s.rfind(x)``, ``s.rindex(x)``) [11]_ [12]_" -msgstr "" +msgstr "反向子字串搜尋(``s.rfind(x)``、``s.rindex(x)``) [11]_ [12]_" #: ../../library/time-complexity.rst:212 msgid "*O*\\ (*n* × len(*x*))" -msgstr "" +msgstr "*O*\\ (*n* × len(*x*))" #: ../../library/time-complexity.rst:213 msgid "Encode or decode [13]_" -msgstr "" +msgstr "編碼或解碼 [13]_" #: ../../library/time-complexity.rst:222 msgid ":class:`!memoryview`" -msgstr "" +msgstr ":class:`!memoryview`" #: ../../library/time-complexity.rst:224 msgid "" @@ -454,38 +487,41 @@ msgid "" "copying. In particular, slicing a memory view returns a new view onto the " "same buffer." msgstr "" +":class:`memoryview` 物件讓 Python 程式碼得以在不複製的情況下,存取支援\\ :" +"ref:`緩衝區協定 `\\ 的物件之內部資料。特別是,對 memoryview 進" +"行切片會回傳指向同一緩衝區的新檢視。" #: ../../library/time-complexity.rst:234 msgid "Create (``memoryview(obj)``)" -msgstr "" +msgstr "建立(``memoryview(obj)``)" #: ../../library/time-complexity.rst:236 msgid "Get item (``v[k]``)" -msgstr "" +msgstr "取得項目(``v[k]``)" #: ../../library/time-complexity.rst:238 msgid "Get slice (``v[i:j]``)" -msgstr "" +msgstr "取得切片(``v[i:j]``)" #: ../../library/time-complexity.rst:240 msgid "Index (``v.index(x)``) [11]_ [14]_" -msgstr "" +msgstr "索引(``v.index(x)``) [11]_ [14]_" #: ../../library/time-complexity.rst:242 msgid "Count (``v.count(x)``) [14]_" -msgstr "" +msgstr "計數(``v.count(x)``) [14]_" #: ../../library/time-complexity.rst:244 msgid "Convert to bytes (``v.tobytes()``, ``bytes(v)``)" -msgstr "" +msgstr "轉換為 bytes(``v.tobytes()``、``bytes(v)``)" #: ../../library/time-complexity.rst:246 msgid "Get length (``len(v)``) [5]_" -msgstr "" +msgstr "取得長度(``len(v)``) [5]_" #: ../../library/time-complexity.rst:251 msgid ":class:`!range`" -msgstr "" +msgstr ":class:`!range`" #: ../../library/time-complexity.rst:253 msgid "" @@ -493,34 +529,36 @@ msgid "" "*stop* and *step* values, so most operations do not depend on the length of " "the range." msgstr "" +":class:`range` 物件會根據其 *start* 值、*stop* 值和 *step* 值即時計算其項目," +"因此大多數操作並不取決於該 range 的長度。" #: ../../library/time-complexity.rst:261 msgid "Get item (``r[k]``)" -msgstr "" +msgstr "取得項目(``r[k]``)" #: ../../library/time-complexity.rst:263 msgid "Get slice (``r[i:j]``)" -msgstr "" +msgstr "取得切片(``r[i:j]``)" #: ../../library/time-complexity.rst:265 msgid "``x in r`` [15]_" -msgstr "" +msgstr "``x in r`` [15]_" #: ../../library/time-complexity.rst:267 msgid "Index and count (``r.index(x)``, ``r.count(x)``) [15]_" -msgstr "" +msgstr "索引與計數(``r.index(x)``、``r.count(x)``) [15]_" #: ../../library/time-complexity.rst:271 msgid "``min(r)``, ``max(r)``" -msgstr "" +msgstr "``min(r)``, ``max(r)``" #: ../../library/time-complexity.rst:273 msgid "Get length (``len(r)``) [5]_" -msgstr "" +msgstr "取得長度(``len(r)``) [5]_" #: ../../library/time-complexity.rst:278 msgid "Notes" -msgstr "" +msgstr "註解" #: ../../library/time-complexity.rst:280 msgid "" @@ -528,6 +566,8 @@ msgid "" "underlying storage is resized, but this cost is spread over many operations, " "depending on the history of the container." msgstr "" +"攤銷。當底層儲存空間被調整大小時,個別操作偶爾可能會是 *O*\\ (*n*),但這項成" +"本會依容器的操作歷史分攤到多次操作之中。" #: ../../library/time-complexity.rst:284 msgid "" @@ -539,12 +579,17 @@ msgid "" "of the list, takes *O*\\ (*n*/2) = *O*\\ (*n*) operations; and operating at " "the end of the list moves nothing and is *O*\\ (1)." msgstr "" +"彈出或刪除大小為 *n* 的 list 中索引 *k* 處的元素,會將 *k* 之後的所有元素向左" +"移動一格,共搬移 *n* - *k* - 1 個元素;在索引 *k* 處插入則會將從 *k* 開始的元" +"素向右移動一格,共搬移 *n* - *k* 個元素。最壞情況是索引 0,此時必須搬移 list " +"其餘的所有元素;平均情況(list 中間的索引)需要 *O*\\ (*n*/2) = *O*\\ (*n*) " +"次操作;而在 list 尾端操作則不需搬移任何元素,為 *O*\\ (1)。" #: ../../library/time-complexity.rst:293 msgid "" "Plus the cost of iterating over *t*, which may be expensive for an arbitrary " "iterable." -msgstr "" +msgstr "加上疊代 *t* 的成本,這對任意的可疊代物件而言可能會很昂貴。" #: ../../library/time-complexity.rst:296 msgid "" @@ -552,17 +597,19 @@ msgid "" "already sorted or reverse-sorted takes only *O*\\ (*n*) comparisons. See :" "source:`Objects/listsort.txt` for more information." msgstr "" +"這是最壞情況。排序具有自適應性,已排序或反向排序的輸入只需要 *O*\\ (*n*) 次比" +"較。詳情請參閱\\ :source:`Objects/listsort.txt`\\ 。" #: ../../library/time-complexity.rst:300 msgid "" "The number of elements is stored in the object, so ``len()`` does not need " "to count them." -msgstr "" +msgstr "元素的數量已經儲存在物件中,因此 ``len()`` 不需要逐一計算它們。" #: ../../library/time-complexity.rst:303 msgid "" "Copying a :class:`frozenset` is *O*\\ (1) as it returns the original object." -msgstr "" +msgstr "複製 :class:`frozenset` 是 *O*\\ (1),因為它會回傳原始物件。" #: ../../library/time-complexity.rst:306 msgid "" @@ -571,14 +618,17 @@ msgid "" "take time proportional to the container's former size, until a later " "insertion triggers a resize." msgstr "" +"這些操作會掃描容器的內部雜湊表,而該雜湊表在元素被移除時並不會縮小。在移除大" +"部分元素之後,這些操作仍然需要花費與容器先前大小成正比的時間,直到之後的一次" +"插入觸發大小調整為止。" #: ../../library/time-complexity.rst:311 msgid "*O*\\ (len(*t*)) if *t* is not a set." -msgstr "" +msgstr "如果 *t* 不是 set,則為 *O*\\ (len(*t*))。" #: ../../library/time-complexity.rst:313 msgid "*O*\\ (len(*s*) + len(*t*)) if *t* is not a set." -msgstr "" +msgstr "如果 *t* 不是 set,則為 *O*\\ (len(*s*) + len(*t*))。" #: ../../library/time-complexity.rst:315 msgid "" @@ -587,12 +637,17 @@ msgid "" "the :ref:`note on concatenating immutable sequences ` for alternatives." msgstr "" +"每一次連接都會建立一個新物件,因此在迴圈中連接許多片段來組成一個字串,其時間" +"會與總長度的平方成正比。其他替代做法請參閱\\ :ref:`關於連接不可變序列的附註 " +"`\\ 。" #: ../../library/time-complexity.rst:320 msgid "" "With *start* and *end* arguments, *n* is the length of the region searched " "rather than of *s*, and unlike slicing nothing is copied." msgstr "" +"當帶有 *start* 和 *end* 引數時,*n* 是搜尋範圍的長度,而不是 *s* 的長度,且與" +"切片不同的是,不會複製任何內容。" #: ../../library/time-complexity.rst:323 msgid "" @@ -601,19 +656,25 @@ msgid "" "case, described in :source:`Objects/stringlib/stringlib_find_two_way_notes." "txt`." msgstr "" +"這是最壞情況。對於一般的輸入,反向搜尋為 *O*\\ (*n*)。正向搜尋則改用一種更精" +"密的演算法,其最壞情況為線性時間,詳情請參閱\\ :source:`Objects/stringlib/" +"stringlib_find_two_way_notes.txt`\\ 。" #: ../../library/time-complexity.rst:328 msgid "This assumes a codec that does a constant amount of work per character." -msgstr "" +msgstr "這是假設編解碼器對每個字元執行固定量的工作。" #: ../../library/time-complexity.rst:330 msgid "" "These unpack and compare each element individually, so they are much slower " "than the equivalent :class:`bytes` methods." msgstr "" +"這些操作會逐一拆解並比較每個元素,因此比對應的 :class:`bytes` 方法慢得多。" #: ../../library/time-complexity.rst:333 msgid "" "Assuming :class:`int` or :class:`bool` arguments. For other types, the range " "is searched like any other sequence in *O*\\ (*n*) time." msgstr "" +"假設引數為 :class:`int` 或 :class:`bool`。對於其他型別,range 會像其他一般序" +"列一樣被搜尋,花費 *O*\\ (*n*) 的時間。" diff --git a/library/time.po b/library/time.po index 1a7ebb34e4..ec97d0e3ce 100644 --- a/library/time.po +++ b/library/time.po @@ -216,7 +216,6 @@ msgid "Functions" msgstr "函式" #: ../../library/time.rst:127 -#, fuzzy msgid "" "Convert a tuple or :class:`struct_time` representing a time as returned by :" "func:`gmtime` or :func:`localtime` to a string of the following form: ``'Sun " @@ -230,13 +229,12 @@ msgstr "" "1993'``。" #: ../../library/time.rst:133 -#, fuzzy msgid "" "If *time_tuple* is not provided, the current time as returned by :func:" "`localtime` is used. Locale information is not used by :func:`asctime`." msgstr "" -"如果沒有提供 *t*,則使用由 :func:`localtime` 回傳的目前時間。:func:`asctime` " -"不使用區域資訊。" +"如果沒有提供 *time_tuple*,則使用由 :func:`localtime` 回傳的目前時間。:func:" +"`asctime` 不使用區域資訊。" #: ../../library/time.rst:139 msgid "" @@ -335,7 +333,6 @@ msgid "Similar to :func:`clock_settime` but set time with nanoseconds." msgstr "類似於 :func:`clock_settime`,但設定以奈秒為單位的時間。" #: ../../library/time.rst:217 -#, fuzzy msgid "" "Convert a time expressed in seconds since the epoch_ to a string of a form: " "``'Sun Jun 20 23:21:05 1993'`` representing local time. The day field is two " @@ -347,16 +344,15 @@ msgstr "" "充,例如:``'Wed Jun 9 04:26:40 1993'``。" #: ../../library/time.rst:222 -#, fuzzy msgid "" "If *seconds* is not provided or :const:`None`, the current time as returned " "by :func:`.time` is used. ``ctime(seconds)`` is equivalent to " "``asctime(localtime(seconds))``. Locale information is not used by :func:" "`ctime`." msgstr "" -"如果未提供 *secs* 或其為 :const:`None`,則使用由 :func:`.time` 回傳的目前時" -"間。``ctime(secs)`` 等同於 ``asctime(localtime(secs))``。:func:`ctime` 不使用" -"區域資訊。" +"如果未提供 *seconds* 或其為 :const:`None`,則使用由 :func:`.time` 回傳的目前" +"時間。``ctime(seconds)`` 等同於 ``asctime(localtime(seconds))``。:func:" +"`ctime` 不使用區域資訊。" #: ../../library/time.rst:230 msgid "" @@ -416,7 +412,6 @@ msgid "*resolution*: The resolution of the clock in seconds (:class:`float`)" msgstr "*resolution*: 以秒 (:class:`float`) 為單位的時鐘的解析度" #: ../../library/time.rst:255 -#, fuzzy msgid "" "Convert a time expressed in seconds since the epoch_ to a :class:" "`struct_time` in UTC in which the dst flag is always zero. If *seconds* is " @@ -426,18 +421,17 @@ msgid "" "of this function." msgstr "" "將自 epoch_ 起以秒表示的時間轉換為 UTC 中的 :class:`struct_time`,其中 dst 旗" -"標始終為零。如果未提供 *secs* 或其為 :const:`None`,則使用由 :func:`.time` 回" -"傳的目前時間。忽略秒的分數部分。關於 :class:`struct_time` 物件的描述,請參閱" -"上文。此函式的反運算請參閱 :func:`calendar.timegm`。" +"標始終為零。如果未提供 *seconds* 或其為 :const:`None`,則使用由 :func:`." +"time` 回傳的目前時間。忽略秒的分數部分。關於 :class:`struct_time` 物件的描" +"述,請參閱上文。此函式的反運算請參閱 :func:`calendar.timegm`。" #: ../../library/time.rst:265 -#, fuzzy msgid "" "Like :func:`gmtime` but converts to local time. If *seconds* is not provided " "or :const:`None`, the current time as returned by :func:`.time` is used. The " "dst flag is set to ``1`` when DST applies to the given time." msgstr "" -"類似於 :func:`gmtime`,但轉換為當地時間。如果未提供 *secs* 或其為 :const:" +"類似於 :func:`gmtime`,但轉換為當地時間。如果未提供 *seconds* 或其為 :const:" "`None`,則使用由 :func:`.time` 回傳的目前時間。當 DST 適用於給定時間時,dst " "旗標會被設定為 ``1``。" @@ -623,7 +617,6 @@ msgid "Windows implementation" msgstr "Windows 實作" #: ../../library/time.rst:398 -#, fuzzy msgid "" "On Windows, if *seconds* is zero, the thread relinquishes the remainder of " "its time slice to any other thread that is ready to run. If there are no " @@ -633,11 +626,11 @@ msgid "" "synchapi-createwaitabletimerexw>`_ which provides resolution of 100 " "nanoseconds. If *seconds* is zero, ``Sleep(0)`` is used." msgstr "" -"在 Windows 上,如果 *secs* 為零,則執行緒將其剩餘的時間片段讓給任何準備運行的" -"其他執行緒。如果沒有其他執行緒準備運行,該函式將立即回傳,而執行緒會繼續執" -"行。在 Windows 10 及更新的版本中,此實作使用\\ `高解析度計時器 `_,其解析度為 100 奈秒。如果 *secs* 為零,則使用 " +"createwaitabletimerexw>`_,其解析度為 100 奈秒。如果 *seconds* 為零,則使用 " "``Sleep(0)``。" #: ../../library/time.rst:410 @@ -671,23 +664,21 @@ msgstr "" "用 :func:`os.sched_yield`。" #: ../../library/time.rst:422 -#, fuzzy msgid "" "Raises an :ref:`auditing event ` ``time.sleep`` with argument " "``seconds``." msgstr "" -"引發一個帶有引數 ``secs`` 的\\ :ref:`稽核事件 (auditing event) ` " -"``time.sleep``。" +"引發一個帶有引數 ``seconds`` 的\\ :ref:`稽核事件 (auditing event) " +"` ``time.sleep``。" #: ../../library/time.rst:424 -#, fuzzy msgid "" "The function now sleeps at least *seconds* even if the sleep is interrupted " "by a signal, except if the signal handler raises an exception (see :pep:" "`475` for the rationale)." msgstr "" -"即使睡眠被訊號中斷,此函式現在至少還是會睡眠 *secs*,除非訊號處理器引發例外" -"(理由請參閱 :pep:`475`)。" +"即使睡眠被訊號中斷,此函式現在至少還是會睡眠 *seconds*,除非訊號處理器引發例" +"外(理由請參閱 :pep:`475`)。" #: ../../library/time.rst:430 msgid "" @@ -702,7 +693,6 @@ msgid "Raises an auditing event." msgstr "引發一個稽核事件。" #: ../../library/time.rst:442 -#, fuzzy msgid "" "Convert a tuple or :class:`struct_time` representing a time as returned by :" "func:`gmtime` or :func:`localtime` to a string as specified by the *format* " @@ -711,9 +701,9 @@ msgid "" "raised if any field in *time_tuple* is outside of the allowed range." msgstr "" "將由 :func:`gmtime` 或 :func:`localtime` 回傳代表時間的一個元組或 :class:" -"`struct_time` 轉換為由 *format* 引數指定的字串。如果未提供 *t*,則使用由 :" -"func:`localtime` 回傳的目前時間。*format* 必須是一個字串。如果 *t* 中的任何欄" -"位超出允許範圍,將會引發 :exc:`ValueError`。" +"`struct_time` 轉換為由 *format* 引數指定的字串。如果未提供 *time_tuple*,則使" +"用由 :func:`localtime` 回傳的目前時間。*format* 必須是一個字串。如果 " +"*time_tuple* 中的任何欄位超出允許範圍,將會引發 :exc:`ValueError`。" #: ../../library/time.rst:448 msgid "" diff --git a/library/tkinter.colorchooser.po b/library/tkinter.colorchooser.po index d7ff30aa1a..dacb97836a 100644 --- a/library/tkinter.colorchooser.po +++ b/library/tkinter.colorchooser.po @@ -42,6 +42,8 @@ msgid "" "use the :func:`askcolor` convenience function rather than instantiating this " "class directly." msgstr "" +"實作互動式顏色選擇對話框的類別。大多數應用程式會使用 :func:`askcolor` 這個便" +"利函式,而不是直接將此類別實例化。" #: ../../library/tkinter.colorchooser.rst:24 msgid "" @@ -52,12 +54,16 @@ msgid "" "color string, such as ``'#ff8000'``. If the user cancels the dialog, " "``(None, None)`` is returned." msgstr "" +"顯示一個互動式顏色選擇對話框,並回傳所選擇的顏色。*color* 是對話框開啟時所選" +"取的顏色。回傳值是一個元組 ``((r, g, b), hexstr)``,其中 ``r``、``g`` 和 " +"``b`` 是紅、綠、藍分量,為範圍 0 到 255 的整數,而 *hexstr* 則是等價的 Tk 顏" +"色字串,例如 ``'#ff8000'``。如果使用者取消對話框,則會回傳 ``(None, None)``。" #: ../../library/tkinter.colorchooser.rst:31 msgid "" "The RGB values in the returned color are now integers in the range 0–255 " "instead of floats." -msgstr "" +msgstr "回傳顏色中的 RGB 值現在是範圍 0 到 255 的整數,而不是浮點數。" #: ../../library/tkinter.colorchooser.rst:38 msgid "Module :mod:`tkinter.commondialog`" diff --git a/library/tkinter.dnd.po b/library/tkinter.dnd.po index bda87a58f9..184ec990ed 100644 --- a/library/tkinter.dnd.po +++ b/library/tkinter.dnd.po @@ -31,7 +31,6 @@ msgid "" msgstr "這是一個實驗性的功能,並將在被 Tk DND 取代時棄用。" #: ../../library/tkinter.dnd.rst:14 -#, fuzzy msgid "" "The :mod:`!tkinter.dnd` module provides drag-and-drop support for objects " "within a single application, within the same window or between windows. To " @@ -45,56 +44,48 @@ msgstr "" ":mod:`!tkinter.dnd` 模組為單一應用程式內、同一個視窗內或視窗之間的物件提供拖" "放支援。要讓一個物件可以被拖動,你必須為它建立一個事件繫結來啟動拖放過程。你" "通常會將一個 ButtonPress 事件繫結到你所寫的回呼函式(請參閱 :ref:`Bindings-" -"and-Events`)。該函式應該呼叫 :func:`dnd_start`,其中 'source' 是要被拖動的物" -"件,而 'event' 是觸發呼叫的事件(你的回呼函式的引數)。" +"and-Events`)。該函式應該呼叫 :func:`dnd_start`,其中 *source* 是要被拖動的物" +"件,而 *event* 是觸發該次呼叫的事件(也就是你的回呼函式的引數)。" #: ../../library/tkinter.dnd.rst:22 msgid "Selection of a target object occurs as follows:" msgstr "目標物件的選擇過程如下:" #: ../../library/tkinter.dnd.rst:24 -#, fuzzy msgid "Top-down search of the area under the mouse for a target widget:" -msgstr "由上而下搜尋滑鼠下方的區域以尋找目標元件(widget)" +msgstr "由上而下搜尋滑鼠下方的區域以尋找目標元件(widget):" #: ../../library/tkinter.dnd.rst:26 -#, fuzzy msgid "the target widget should have a callable *dnd_accept* attribute;" -msgstr "目標元件應該要有一個可呼叫的 *dnd_accept* 屬性(attribute)" +msgstr "目標元件應該要有一個可呼叫的 *dnd_accept* 屬性(attribute);" #: ../../library/tkinter.dnd.rst:27 -#, fuzzy msgid "" "if *dnd_accept* is not present or returns ``None``, the search moves to the " "parent widget;" -msgstr "如果 *dnd_accept* 不存在或回傳 ``None``,搜尋會移至父元件" +msgstr "如果 *dnd_accept* 不存在或回傳 ``None``,搜尋會移至父元件;" #: ../../library/tkinter.dnd.rst:29 -#, fuzzy msgid "if no target widget is found, the target object is ``None``." -msgstr "如果找不到目標元件,則目標物件為 ``None``" +msgstr "如果找不到目標元件,則目標物件為 ``None``。" #: ../../library/tkinter.dnd.rst:31 -#, fuzzy msgid "Call to ``.dnd_leave(source, event)``." -msgstr "呼叫 *.dnd_leave(source, event)*" +msgstr "呼叫 ``.dnd_leave(source, event)``。" #: ../../library/tkinter.dnd.rst:32 -#, fuzzy msgid "Call to ``.dnd_enter(source, event)``." -msgstr "呼叫 *.dnd_enter(source, event)*" +msgstr "呼叫 ``.dnd_enter(source, event)``。" #: ../../library/tkinter.dnd.rst:33 -#, fuzzy msgid "Call to ``.dnd_commit(source, event)`` to notify of the drop." -msgstr "呼叫 *.dnd_commit(source, event)* 以通知放下動作" +msgstr "呼叫 ``.dnd_commit(source, event)`` 以通知放下動作。" #: ../../library/tkinter.dnd.rst:34 -#, fuzzy msgid "" "Call to ``.dnd_end(target, event)`` to signal the end of drag-and-" "drop." -msgstr "呼叫 *.dnd_end(target, event)* 以表示拖放結束" +msgstr "呼叫 ``.dnd_end(target, event)`` 以表示拖放結束。" #: ../../library/tkinter.dnd.rst:39 msgid "" @@ -126,6 +117,8 @@ msgid "" "`DndHandler` instance managing the drag, or ``None`` if a drag could not be " "started." msgstr "" +"用於拖放過程的工廠函式。回傳管理該次拖放的 :class:`DndHandler` 實例,如果無法" +"啟動拖放則回傳 ``None``。" #: ../../library/tkinter.dnd.rst:67 msgid ":ref:`Bindings-and-Events`" diff --git a/library/tkinter.font.po b/library/tkinter.font.po index e3c180d752..a10616c496 100644 --- a/library/tkinter.font.po +++ b/library/tkinter.font.po @@ -53,6 +53,8 @@ msgid "" "Two fonts now compare equal (``==``) only when both are :class:`Font` " "instances with the same name belonging to the same Tcl interpreter." msgstr "" +"現在只有當兩個字型都是屬於同一個 Tcl 直譯器且名稱相同的 :class:`Font` 實例" +"時,兩者才會比較相等 (``==``)。" #: ../../library/tkinter.font.rst:33 msgid "arguments:" @@ -118,6 +120,9 @@ msgid "" "that single attribute. The attributes are resolved on the display of the " "*displayof* widget, or the main application window if it is not specified." msgstr "" +"回傳字型的實際屬性,這可能會因為平台限制而與所要求的不同。若沒有指定 " +"*option*,則回傳包含所有屬性的 dictionary;若有指定 *option*,則回傳該單一屬" +"性的值。" #: ../../library/tkinter.font.rst:62 msgid "Retrieve an attribute of the font." @@ -128,10 +133,11 @@ msgid "" "Modify one or more attributes of the font. With no arguments, return a " "dictionary of the current attributes." msgstr "" +"修改字型的一個或多個屬性。若沒有引數,則回傳包含目前屬性的 dictionary。" #: ../../library/tkinter.font.rst:72 msgid ":meth:`config` is an alias of :meth:`!configure`." -msgstr "" +msgstr ":meth:`config` 是 :meth:`!configure` 的別名。" #: ../../library/tkinter.font.rst:76 msgid "" @@ -140,6 +146,9 @@ msgid "" "the original. If the current font wraps a font description, the copy is " "instead a named font with its resolved attributes." msgstr "" +"回傳目前字型的獨立副本:一個具有相同屬性但名稱不同的新已命名字型,可以獨立於" +"原字型重新設定。若目前字型包裝了一個字型描述,則該副本會是一個具有已解析屬性" +"的已命名字型。" #: ../../library/tkinter.font.rst:84 msgid "" @@ -156,6 +165,8 @@ msgid "" "metric name to its integer value; if one option name is given, return that " "metric's value as an integer. Options include:" msgstr "" +"回傳字型特定的資料。若沒有指定選項,則回傳將每個度量名稱對映至其整數值的 " +"dictionary;若有指定一個選項名稱,則以整數回傳該度量的值。其選項包含:" #: ../../library/tkinter.font.rst:96 msgid "*ascent* - distance between baseline and highest point that a" @@ -195,6 +206,8 @@ msgid "" "*root* is the widget whose Tcl interpreter owns the font; if omitted, the " "default root window is used." msgstr "" +"回傳一個 :class:`Font`,代表現有已命名字型 *name*。*root* 為擁有該字型所屬 " +"Tcl 直譯器的元件;若省略,則使用預設的根視窗。" #: ../../library/tkinter.font.rst:121 msgid "The *root* parameter was added." diff --git a/library/tkinter.messagebox.po b/library/tkinter.messagebox.po index 6258fd6bce..8a65c8ad01 100644 --- a/library/tkinter.messagebox.po +++ b/library/tkinter.messagebox.po @@ -26,7 +26,6 @@ msgid "**Source code:** :source:`Lib/tkinter/messagebox.py`" msgstr "**原始碼:**\\ :source:`Lib/tkinter/messagebox.py`" #: ../../library/tkinter.messagebox.rst:11 -#, fuzzy msgid "" "The :mod:`!tkinter.messagebox` module provides a template base class as well " "as a variety of convenience methods for commonly used configurations. The " @@ -39,9 +38,8 @@ msgstr "" ":mod:`!tkinter.messagebox` 模組提供了模板基底類別以及各種常用配置的便捷方法。" "訊息框 (message box) 是互動視窗 (modal):每個訊息框會阻塞執行直到使用者回應," "然後回傳一個取決於函式的值。``show*`` 函式和 :meth:`Message.show` 以字串形式" -"回傳使用者按下的按鈕的符號名稱(例如 :data:`OK` 或 :data:`YES`),而 " -"``ask*`` 函式則回傳 :class:`bool` 或 ``None`` (請參閱以下各函式)。常見的訊" -"息框樣式 (style) 和版面配置 (layout) 包括但不限於:" +"回傳使用者按下的按鈕的符號名稱(例如 :data:`OK` 或 :data:`YES`)。常見的訊息" +"框樣式 (style) 和版面配置 (layout) 包括但不限於:" #: ../../library/tkinter.messagebox.rst:23 msgid "" @@ -156,7 +154,7 @@ msgstr "安排一組需顯示的\\ :ref:`預先定義的按鈕組合 ` class instead. The three ways of setting an option shown above " "apply to both widget sets." msgstr "" +"這裡使用的 ``fg`` 和 ``bg`` 選項,以及其他控制元件外觀的選項,都屬於傳統的 :" +"mod:`!tkinter` 元件。簡介中建議使用的主題式 :mod:`tkinter.ttk` 元件並不接受這" +"些選項;若要為主題式元件設定樣式,請改用 :class:`ttk.Style ` 類別。上面展示的三種設定選項的方式,這兩種元件集皆適用。" #: ../../library/tkinter.rst:536 msgid "" @@ -1141,6 +1144,8 @@ msgid "" "Some options, like ``bg``, are synonyms for common options with long names " "(``bg`` is shorthand for \"background\")." msgstr "" +"某些選項,如 ``bg``,是具有較長名稱之常見選項的同義詞(``bg`` 是" +"「background」的縮寫)。" #: ../../library/tkinter.rst:560 msgid "Index" @@ -1229,9 +1234,8 @@ msgid "" msgstr "當然,印出的字典將包含所有可用的選項及其值。這僅作為一個範例。" #: ../../library/tkinter.rst:589 -#, fuzzy msgid "Geometry management" -msgstr "佈局管理(geometry management)" +msgstr "佈局管理" #: ../../library/tkinter.rst:595 msgid "" @@ -1241,6 +1245,10 @@ msgid "" "resized or its content changes. Forgetting to call a geometry manager is a " "common early mistake: the widget is created, but nothing shows up." msgstr "" +"建立元件並不會顯示它。元件唯有在被交給\\ *佈局管理器*\\ 之後才會顯示出來,佈" +"局管理器會計算它在容器中的大小與位置,並在容器被調整大小或其內容變化時,讓版" +"面保持最新狀態。忘記呼叫佈局管理器是初學者常犯的錯誤:元件雖然已建立,畫面上" +"卻什麼都沒顯示。" #: ../../library/tkinter.rst:602 msgid "" @@ -1249,10 +1257,13 @@ msgid "" "the incompatibility of grid and pack). The choice depends on the kind of " "layout you want." msgstr "" +"Tk 提供了三種佈局管理器,每一種都由每個元件所繼承,因此任何元件都可以由其中任" +"何一種來管理(但請參閱下方關於 grid 和 pack 不相容的警告)。該選擇哪一種,則" +"取決於你想要的版面類型。" #: ../../library/tkinter.rst:607 msgid ":meth:`grid `" -msgstr "" +msgstr ":meth:`grid `" #: ../../library/tkinter.rst:608 msgid "" @@ -1261,6 +1272,9 @@ msgid "" "would otherwise need several nested frames can often be expressed as a " "single grid, and rows and columns can be told how to absorb extra space." msgstr "" +"將元件排列成由列與欄組成的二維表格。它是最具彈性的管理器,也是預設情況下應優" +"先選用的方式:原本需要多層巢狀框架才能表達的版面,通常都可以用單一個網格來表" +"示,而且可以指定列與欄該如何吸收多餘的空間。" #: ../../library/tkinter.rst:616 msgid "" @@ -1268,10 +1282,13 @@ msgid "" "ttk.Entry(frm).grid(column=1, row=0)\n" "ttk.Button(frm, text=\"OK\").grid(column=1, row=1, sticky=\"e\")" msgstr "" +"ttk.Label(frm, text=\"Name:\").grid(column=0, row=0, sticky=\"w\")\n" +"ttk.Entry(frm).grid(column=1, row=0)\n" +"ttk.Button(frm, text=\"OK\").grid(column=1, row=1, sticky=\"e\")" #: ../../library/tkinter.rst:620 msgid ":meth:`pack `" -msgstr "" +msgstr ":meth:`pack `" #: ../../library/tkinter.rst:621 msgid "" @@ -1281,6 +1298,10 @@ msgid "" "arrangements, such as a single row or column of widgets or a content area " "framed by a toolbar and a status bar." msgstr "" +"將元件堆疊靠向容器的其中一側 -- ``\"top\"``\\ (預設值)、``\"bottom\"``、" +"``\"left\"`` 或 ``\"right\"`` -- 並可以讓它們填滿或擴展到剩餘的空間中。這對於" +"簡單的排列方式很方便,例如單一列或欄的元件,或是由工具列與狀態列所框住的內容" +"區域。" #: ../../library/tkinter.rst:630 msgid "" @@ -1288,10 +1309,13 @@ msgid "" "status.pack(side=\"bottom\", fill=\"x\")\n" "body.pack(side=\"left\", expand=True, fill=\"both\")" msgstr "" +"toolbar.pack(side=\"top\", fill=\"x\")\n" +"status.pack(side=\"bottom\", fill=\"x\")\n" +"body.pack(side=\"left\", expand=True, fill=\"both\")" #: ../../library/tkinter.rst:634 msgid ":meth:`place `" -msgstr "" +msgstr ":meth:`place `" #: ../../library/tkinter.rst:635 msgid "" @@ -1300,12 +1324,17 @@ msgid "" "control but the least automatic behavior, and is used the least; it suits " "special cases such as overlapping widgets or precise custom layouts." msgstr "" +"將每個元件放置在明確指定的位置,該位置可以是絕對的螢幕距離,也可以是容器大小" +"的比例。它提供了最多的控制能力,但自動化程度最低,也是使用最少的管理器;適合" +"用於特殊情況,例如重疊的元件或需要精確自訂的版面。" #: ../../library/tkinter.rst:642 msgid "" "background.place(x=0, y=0, relwidth=1.0, relheight=1.0)\n" "badge.place(relx=1.0, rely=0.0, anchor=\"ne\")" msgstr "" +"background.place(x=0, y=0, relwidth=1.0, relheight=1.0)\n" +"badge.place(relx=1.0, rely=0.0, anchor=\"ne\")" #: ../../library/tkinter.rst:645 msgid "" @@ -1313,6 +1342,9 @@ msgid "" "inside a frame or toplevel. Toplevels are managed by the OS window manager. " "Classic and themed :mod:`tkinter.ttk` widgets can be managed interchangeably." msgstr "" +"版面配置是以巢狀方式建立的:將元件(包括框架)以 grid 或 pack 的方式放入某個" +"框架或頂層視窗中。頂層視窗由作業系統的視窗管理器負責管理。傳統與主題式的 :" +"mod:`tkinter.ttk` 元件可以交替搭配使用。" #: ../../library/tkinter.rst:652 msgid "" @@ -1321,6 +1353,9 @@ msgid "" "the application can hang as they repeatedly resize the container against " "each other. To combine them, keep each manager's widgets in a separate frame." msgstr "" +"不要對共用同一個容器的兩個元件同時套用 :meth:`!pack` 和 :meth:`!grid`。這兩種" +"管理器協商大小的方式互不相容,應用程式可能會因為它們不斷互相調整容器大小而卡" +"住。若要同時使用兩者,請將各個管理器所管理的元件分別放在不同的框架中。" #: ../../library/tkinter.rst:657 msgid "" @@ -1329,13 +1364,16 @@ msgid "" "pack_configure` and :meth:`Place.place_configure`; see also the :manpage:" "`grid(3tk)`, :manpage:`pack(3tk)` and :manpage:`place(3tk)` man pages." msgstr "" +"每種管理器所接受的完整選項組合,連同其值與預設值,都記錄在 :meth:`Grid." +"grid_configure`、:meth:`Pack.pack_configure` 和 :meth:`Place." +"place_configure` 之中;另請參閱 :manpage:`grid(3tk)`、:manpage:`pack(3tk)` " +"和 :manpage:`place(3tk)` man pages。" #: ../../library/tkinter.rst:667 msgid "Coupling widget variables" msgstr "耦合元件變數" #: ../../library/tkinter.rst:669 -#, fuzzy msgid "" "Some widgets can tie their current value directly to a program variable, so " "that the two stay in sync. Options such as ``variable``, ``textvariable``, " @@ -1343,10 +1381,10 @@ msgid "" "user changes the widget the variable is updated, and when the variable is " "set the widget redraws to match." msgstr "" -"某些元件(如文字輸入元件)的目前值設定可以透過使用特殊選項直接連接到應用程式" -"變數。這些選項是 ``variable``、``textvariable``、``onvalue``、``offvalue`` " -"和 ``value``。這種連接是雙向的:如果變數因任何原因發生變化,與之連接的元件將" -"會更新以反映新值。" +"某些元件可以將目前的值直接連結到程式變數,使兩者保持同步。像 ``variable``、" +"``textvariable``、``value``、``onvalue`` 和 ``offvalue`` 這類選項會建立這種連" +"結:當使用者變更元件時,變數會隨之更新;而當變數被設定時,元件也會重新繪製以" +"反映該值。" #: ../../library/tkinter.rst:676 msgid "" @@ -1358,9 +1396,14 @@ msgid "" "keeping its value inside the Tcl interpreter and exposing it through " "explicit :meth:`~Variable.get` and :meth:`~Variable.set` methods." msgstr "" +"元件只能連結到 :class:`Variable` 物件,而不能連結到一般的 Python 變數。這並" +"非 :mod:`!tkinter` 本身的限制,而是這兩種語言差異所造成的結果:這種連結仰賴 " +"Tcl 在數值每次變更時都能收到通知,但 Python 沒有辦法在一般變數被重新賦值時做" +"出反應。:class:`Variable` 透過將其值保存在 Tcl 直譯器內部,並透過明確的 :" +"meth:`~Variable.get` 和 :meth:`~Variable.set` 方法來公開該值,藉此避開這個問" +"題。" #: ../../library/tkinter.rst:685 -#, fuzzy msgid "" "Ready-made subclasses cover the common types: :class:`StringVar`, :class:" "`IntVar`, :class:`DoubleVar` and :class:`BooleanVar`. Pass one as a widget's " @@ -1368,10 +1411,11 @@ msgid "" "meth:`~Variable.get` and :meth:`~Variable.set`; the widget tracks it with no " "further work on your part." msgstr "" -"已經定義了許多有用的 Variable 子類別::class:`StringVar`、:class:`IntVar`、:" -"class:`DoubleVar` 和 :class:`BooleanVar`。要讀取此類變數的目前值,請對其呼" -"叫 :meth:`~Variable.get` 方法,要更改其值,則呼叫 :meth:`!set` 方法。如果你遵" -"循此協定,元件將始終追蹤變數的值,無需你進一步干預。" +"現成的子類別涵蓋了常見的型別::class:`StringVar`、:class:`IntVar`、:class:" +"`DoubleVar` 和 :class:`BooleanVar`。將其中一個實例傳入元件的 " +"``textvariable``\\ (或 ``variable``)選項,然後使用 :meth:`~Variable.get` " +"和 :meth:`~Variable.set` 來讀取和更新它;元件會自動追蹤它,不需要你再做其他" +"事。" #: ../../library/tkinter.rst:691 msgid "" @@ -1380,6 +1424,8 @@ msgid "" "collected removes its underlying Tcl variable, breaking the connection to " "the widget (see :class:`Variable`)." msgstr "" +"只要有元件在使用該變數,就應保留對該變數的參照,例如將其儲存為屬性(請參閱 :" +"class:`Variable`)。" #: ../../library/tkinter.rst:696 ../../library/tkinter.rst:746 #: ../../library/tkinter.rst:887 @@ -1415,6 +1461,31 @@ msgid "" "\n" "root.mainloop()" msgstr "" +"import tkinter as tk\n" +"from tkinter import ttk\n" +"\n" +"root = tk.Tk()\n" +"\n" +"# 建立應用程式變數,並給予它一個初始值。\n" +"contents = tk.StringVar(value=\"this is a variable\")\n" +"\n" +"# 告訴 entry 元件追蹤此變數。\n" +"entry = ttk.Entry(root, textvariable=contents)\n" +"entry.pack()\n" +"\n" +"# 每當使用者按下 Return 鍵時,印出目前的值。\n" +"def print_contents(event):\n" +" print(\"The current entry content is:\", contents.get())\n" +"\n" +"entry.bind(\"\", print_contents)\n" +"\n" +"# 從程式設定變數,會透過相同的連結更新 entry 元件。\n" +"def clear():\n" +" contents.set(\"\")\n" +"\n" +"ttk.Button(root, text=\"Clear\", command=clear).pack()\n" +"\n" +"root.mainloop()" #: ../../library/tkinter.rst:728 msgid "The window manager" @@ -1431,6 +1502,12 @@ msgid "" "equivalent ``wm_``-prefixed name, for example :meth:`~Wm.title` and :meth:" "`~Wm.wm_title`." msgstr "" +"\\ *視窗管理器*\\ 是桌面環境中負責繪製每個頂層視窗周圍的標題列、邊框與控制項" +"的部分,也負責標題、位置、大小和圖示等事項。Tk 透過 :class:`Wm` mixin 提供對" +"這些功能的存取,該 mixin 被 :class:`Tk` 根視窗與每個 :class:`Toplevel` 所繼" +"承。因此,你可以直接在頂層視窗上呼叫視窗管理器的方法。每個方法都有一個簡短名" +"稱,以及一個對應的、帶有 ``wm_`` 前綴的名稱,例如 :meth:`~Wm.title` 和 :meth:" +"`~Wm.wm_title`。" #: ../../library/tkinter.rst:741 msgid "" @@ -1439,6 +1516,9 @@ msgid "" "top-level window containing an arbitrary widget, call its :meth:`~Misc." "winfo_toplevel` method." msgstr "" +"無論頂層視窗的內容是以傳統元件還是主題式 :mod:`tkinter.ttk` 元件建構而成,這" +"些方法都能作用於該頂層視窗。若要取得包含任意元件的頂層視窗,請對該元件呼叫 :" +"meth:`~Misc.winfo_toplevel` 方法。" #: ../../library/tkinter.rst:748 msgid "" @@ -1454,10 +1534,21 @@ msgid "" "\n" "root.mainloop()" msgstr "" +"import tkinter as tk\n" +"from tkinter import ttk\n" +"\n" +"root = tk.Tk()\n" +"root.title(\"My Application\")\n" +"root.geometry(\"640x480\")\n" +"root.minsize(320, 240)\n" +"\n" +"ttk.Label(root, text=\"Hello\").pack(padx=20, pady=20)\n" +"\n" +"root.mainloop()" #: ../../library/tkinter.rst:760 msgid "See :class:`Wm` for the full set of window-manager methods." -msgstr "" +msgstr "完整的視窗管理器方法集合,請參閱 :class:`Wm`。" #: ../../library/tkinter.rst:766 msgid "Tk option data types" @@ -1468,6 +1559,8 @@ msgid "" "Many widget options documented in the reference accept values of a small " "number of common types, described here." msgstr "" +"參考文件中所記載的許多元件選項,都接受少數幾種常見型別的值,這裡將說明這些型" +"別。" #: ../../library/tkinter.rst:773 msgid "anchor" @@ -1530,7 +1623,6 @@ msgid "color" msgstr "color" #: ../../library/tkinter.rst:795 -#, fuzzy msgid "" "Colors can be given as the names of X colors in the rgb.txt file, or as " "strings representing RGB values in 4 bit: ``\"#RGB\"``, 8 bit: " @@ -1541,14 +1633,14 @@ msgstr "" "顏色可以以 rgb.txt 檔案中的 X 顏色名稱給出,或以表示 RGB 值的字串給出,範圍可" "以是 4 位元:``\"#RGB\"``、8 位元:``\"#RRGGBB\"``、12 位元:" "``\"#RRRGGGBBB\"`` 或 16 位元:``\"#RRRRGGGGBBBB\"``,其中 R、G、B 在此代表任" -"何合法的十六進位數字。詳情請參閱 Ousterhout 書中的第 160 頁。" +"何合法的十六進位數字。已命名顏色的清單請參閱 :manpage:`colors(3tk)` man " +"page。" #: ../../library/tkinter.rst:801 msgid "cursor" msgstr "cursor" -#: ../../library/tkinter.rst:802 -#, fuzzy +#: ../../library/tkinter.rst:777 msgid "" "The name of the mouse cursor to display while the pointer is over the " "widget. Tk provides a portable set of cursor names available on all " @@ -1563,7 +1655,9 @@ msgid "" msgstr "" "可以使用 :file:`cursorfont.h` 中的標準 X 游標名稱,無需 ``XC_`` 前綴。例如," "要取得手形游標(``XC_hand2``),請使用字串 ``\"hand2\"``。你也可以指定自己的" -"點陣圖和遮罩檔案。請參閱 Ousterhout 書中的第 179 頁。" +"點陣圖和遮罩檔案。在 Windows 上,可以直接使用游標檔案(:file:`.cur` 或 :file:" +"`.ani`),並在其路徑前加上 ``@``,如 ``\"@C:/cursors/bart.ani\"``。請參閱 " +"Ousterhout 書中的第 179 頁。" #: ../../library/tkinter.rst:813 msgid "distance" @@ -1695,7 +1789,6 @@ msgid "sequence" msgstr "sequence" #: ../../library/tkinter.rst:870 -#, fuzzy msgid "" "is a string that denotes the target kind of event. Physical events use the " "```` form (for example ``\"\"`` or " @@ -1705,9 +1798,8 @@ msgid "" msgstr "" "是一個表示目標事件類型的字串。實體事件使用 ```` 形式(例如 ``\"\"`` 或 ``\"\"``);應用程" -"式定義的虛擬事件使用雙角括號,如 ``\"<>\"``. (詳情請參閱 :manpage:" -"`bind(3tk)` man page,以及 John Ousterhout 的書 :title-reference:`Tcl and " -"the Tk Toolkit (2nd edition)` 的第 201 頁)。" +"式定義的虛擬事件則使用雙角括號,如 ``\"<>\"``。(詳情請參閱 :manpage:" +"`bind(3tk)` man page。)" #: ../../library/tkinter.rst:876 msgid "func" @@ -1895,35 +1987,35 @@ msgstr "y_root" #: ../../library/tkinter.rst:918 msgid "%#" -msgstr "" +msgstr "%#" #: ../../library/tkinter.rst:918 msgid "serial" -msgstr "" +msgstr "serial" #: ../../library/tkinter.rst:918 msgid "%b" -msgstr "" +msgstr "%b" #: ../../library/tkinter.rst:918 msgid "num" -msgstr "" +msgstr "num" #: ../../library/tkinter.rst:920 msgid "%d" -msgstr "" +msgstr "%d" #: ../../library/tkinter.rst:920 msgid "detail" -msgstr "" +msgstr "detail" #: ../../library/tkinter.rst:920 msgid "%D" -msgstr "" +msgstr "%D" #: ../../library/tkinter.rst:920 msgid "delta" -msgstr "" +msgstr "delta" #: ../../library/tkinter.rst:923 msgid "" @@ -1933,6 +2025,10 @@ msgid "" "transpose two characters. These are described in the bindings section of the " "widget's Tk man page (such as :manpage:`text(3tk)` or :manpage:`entry(3tk)`)." msgstr "" +"上述的 ``add`` 參數只會影響你自己所建立的繫結。每個元件也會繼承實作其標準行為" +"的\\ *類別繫結*\\ ——例如 :class:`Text` 元件會將 :kbd:`Control-t` 繫結為交換兩" +"個字元。這些內容記載在該元件 Tk man page 的繫結(bindings)小節中(例如 :" +"manpage:`text(3tk)` 或 :manpage:`entry(3tk)`)。" #: ../../library/tkinter.rst:931 msgid "" @@ -1941,6 +2037,9 @@ msgid "" "default binding, bind the event on the widget and return the string " "``\"break\"`` from your callback." msgstr "" +"類別繫結與你自己的繫結是分開處理的,因此自行繫結一個事件並不會取代預設行為;" +"兩者都會執行。若要抑制不想要的預設繫結,請在元件上繫結該事件,並從你的回呼函" +"式中回傳字串 ``\"break\"``。" #: ../../library/tkinter.rst:939 msgid "The index parameter" @@ -1960,41 +2059,37 @@ msgid "Entry widget indexes (index, view index, etc.)" msgstr "Entry 元件索引(index、view index 等)" #: ../../library/tkinter.rst:946 -#, fuzzy msgid "" "Entry widgets have methods and options that refer to character positions in " "the text being displayed. Anytime an index is needed, you may pass in:" msgstr "" -"Entry 元件具有參照所顯示文字中字元位置的選項。你可以使用這些 :mod:`!tkinter` " -"函式來存取文字元件中的這些特殊點:" +"Entry 元件具有參照其顯示文字中字元位置的方法和選項。每當需要索引時,你都可以" +"傳入:" #: ../../library/tkinter.rst:950 -#, fuzzy msgid "" "an integer which refers to the numeric position of a character, counted from " "the beginning of the text, starting with 0;" -msgstr "一個整數,它參照元件中項目的數字位置,從頂部開始計數,從 0 開始;" +msgstr "一個整數,它參照字元從文字開頭起算的數字位置,從 0 開始計數;" #: ../../library/tkinter.rst:953 -#, fuzzy msgid "" "the string ``\"anchor\"``, which refers to the anchor point of the " "selection, set with the widget's selection methods;" -msgstr "字串 ``\"active\"``,它參照目前在游標下的選單位置;" +msgstr "" +"字串 ``\"anchor\"``,它參照選取範圍的錨點,該錨點由元件的選取方法設定;" #: ../../library/tkinter.rst:957 -#, fuzzy msgid "" "the string ``\"end\"``, which refers to the position just after the last " "character;" -msgstr "字串 ``\"active\"``,它參照目前在游標下的選單位置;" +msgstr "字串 ``\"end\"``,它參照緊接在最後一個字元之後的位置;" #: ../../library/tkinter.rst:960 -#, fuzzy msgid "" "the string ``\"insert\"``, which refers to the character just after the " "insertion cursor;" -msgstr "字串 ``\"active\"``,它參照目前在游標下的選單位置;" +msgstr "字串 ``\"insert\"``,它參照緊接在插入游標之後的字元;" #: ../../library/tkinter.rst:963 msgid "" @@ -2002,16 +2097,18 @@ msgid "" "character in the selection and the position just after the last (it is an " "error to use these if there is no selection);" msgstr "" +"字串 ``\"sel.first\"`` 和 ``\"sel.last\"``,分別參照選取範圍中的第一個字元," +"以及緊接在最後一個字元之後的位置(如果沒有選取範圍,使用這些字串會發生錯" +"誤);" #: ../../library/tkinter.rst:968 -#, fuzzy msgid "" "a string consisting of ``@`` followed by an integer, as in ``\"@6\"``, where " "the integer is interpreted as an x pixel coordinate in the entry's " "coordinate system, selecting the character spanning that point." msgstr "" -"一個以 ``@`` 為前綴的整數,如 ``@6``,其中該整數被解釋為選單座標系統中的 y 像" -"素座標;" +"一個以 ``@`` 為前綴的整數所組成的字串,如 ``\"@6\"``,其中該整數被解釋為 " +"Entry 元件座標系統中的 x 像素座標,用以選取該點所在範圍內的字元。" #: ../../library/tkinter.rst:973 msgid "Text widget indexes" @@ -2052,7 +2149,6 @@ msgid "the string ``\"last\"`` which refers to the last menu item;" msgstr "字串 ``\"last\"``,它參照最後一個選單項目;" #: ../../library/tkinter.rst:989 -#, fuzzy msgid "" "a string consisting of ``@`` followed by an integer, as in ``\"@6\"``, where " "the integer is interpreted as a y pixel coordinate in the menu's coordinate " @@ -2155,16 +2251,20 @@ msgid "" "official Tcl/Tk manual pages for the full list of widget options and further " "details." msgstr "" +"本節記載了 :mod:`!tkinter` 模組的類別、方法、函式和常數。其中大多數是對 Tcl/" +"Tk 指令的包裝;如需元件選項的完整清單和更多細節,請查閱官方的 Tcl/Tk 手冊頁" +"面。" #: ../../library/tkinter.rst:1050 msgid "" "The exception raised when a call into the Tcl interpreter fails, for example " "when a widget is given an unknown option or an invalid value." msgstr "" +"當呼叫 Tcl 直譯器失敗時所引發的例外,例如給予元件一個未知的選項或無效的值時。" #: ../../library/tkinter.rst:1054 msgid "Base and mixin classes" -msgstr "" +msgstr "基底類別與混合類別" #: ../../library/tkinter.rst:1058 msgid "" @@ -2177,6 +2277,12 @@ msgid "" "methods are available on every widget and on the :class:`Tk` application " "object, and are documented here once rather than repeated for each widget." msgstr "" +":class:`!Misc` 類別是一個混合類別(mixin),被 :class:`Tk` 繼承,並透過 :" +"class:`BaseWidget` 被每個元件繼承。它提供了所有 Tk 物件共通的大量方法:查詢視" +"窗資訊、管理事件繫結和事件迴圈、控制鍵盤焦點和指標捕獲(grab)、存取選取範" +"圍、剪貼簿和選項資料庫,以及各種工具和自省服務。由於這些方法是被繼承的,因此" +"它們在每個元件和 :class:`Tk` 應用程式物件上都可用,本文件在此統一記載一次,而" +"不會針對每個元件重複說明。" #: ../../library/tkinter.rst:1070 msgid "" @@ -2184,6 +2290,8 @@ msgid "" "widget, as a string. The expression ``widget[key]`` is equivalent and may be " "used instead." msgstr "" +"以字串形式回傳此元件名為 *key* 的設定選項目前的值。運算式 ``widget[key]`` 是" +"等效的,可用來替代此方法。" #: ../../library/tkinter.rst:1079 msgid "" @@ -2196,14 +2304,19 @@ msgid "" "value; the expression ``widget[key] = value`` sets a single option in the " "same way." msgstr "" +"查詢或修改元件的設定選項。若不帶引數呼叫,會回傳一個字典,將每個可用的選項名" +"稱對映到描述它的一個 tuple(其名稱、X 資源名稱、X 資源類別、預設值和目前" +"值)。若以字串形式給出單一選項名稱,則只回傳該選項的 tuple。若給出一個或多個" +"關鍵字引數,或將一個字典作為 *cnf* 傳入,則會將每個具名選項設定為對應的值;運" +"算式 ``widget[key] = value`` 也是以相同方式設定單一選項。" #: ../../library/tkinter.rst:1089 msgid ":meth:`config` is an alias of :meth:`!configure`." -msgstr "" +msgstr ":meth:`config` 是 :meth:`!configure` 的別名。" #: ../../library/tkinter.rst:1093 msgid "Return a list of the names of all configuration options of this widget." -msgstr "" +msgstr "回傳此元件所有設定選項名稱的串列。" #: ../../library/tkinter.rst:1097 msgid "" @@ -2212,26 +2325,33 @@ msgid "" "``'no'``, ``'true'`` and ``'false'``. Raise :exc:`ValueError` if *s* is not " "a valid boolean." msgstr "" +"將字串 *s* 解釋為 Tcl 布林值,並回傳對應的 :class:`bool`。Tcl 接受諸如 " +"``'1'``、``'0'``、``'yes'``、``'no'``、``'true'`` 和 ``'false'`` 之類的值。如" +"果 *s* 不是有效的布林值,則引發 :exc:`ValueError`。" #: ../../library/tkinter.rst:1105 msgid "" "Interpret the string *s* as a Tcl floating-point number and return it as a :" "class:`float`. Raise :exc:`ValueError` if *s* is not a valid number." msgstr "" +"將字串 *s* 解釋為 Tcl 浮點數,並以 :class:`float` 形式回傳。如果 *s* 不是有效" +"的數字,則引發 :exc:`ValueError`。" #: ../../library/tkinter.rst:1114 msgid "" "Interpret the string *s* as a Tcl integer and return it as an :class:`int`. " "Raise :exc:`ValueError` if *s* is not a valid integer." msgstr "" +"將字串 *s* 解釋為 Tcl 整數,並以 :class:`int` 形式回傳。如果 *s* 不是有效的整" +"數,則引發 :exc:`ValueError`。" #: ../../library/tkinter.rst:1120 msgid "Return the value of the Tcl global variable named *name*." -msgstr "" +msgstr "回傳名為 *name* 的 Tcl 全域變數的值。" #: ../../library/tkinter.rst:1124 msgid "Set the Tcl global variable named *name* to *value*." -msgstr "" +msgstr "將名為 *name* 的 Tcl 全域變數設定為 *value*。" #: ../../library/tkinter.rst:1126 msgid "" @@ -2240,6 +2360,9 @@ msgid "" "such as :class:`StringVar` or :class:`IntVar`, which wraps a Tcl variable " "and converts its value to and from a Python type." msgstr "" +":meth:`!getvar` 和 :meth:`!setvar` 方法可直接存取 Tcl 變數。在大多數程式碼" +"中,你會改用 :class:`Variable` 的子類別,例如 :class:`StringVar` 或 :class:" +"`IntVar`,它們包裝了一個 Tcl 變數,並在 Python 型別之間轉換其值。" #: ../../library/tkinter.rst:1134 msgid "" @@ -2250,20 +2373,25 @@ msgid "" "command names passed to Tk options such as *command*. Unless *needcleanup* " "is false, the command is deleted automatically when the widget is destroyed." msgstr "" +"將 Python 可呼叫物件 *func* 註冊為 Tcl 指令,並以字串形式回傳新指令的名稱。每" +"當 Tcl 呼叫該指令時,就會呼叫 *func*;如果給出了 *subst*,會先將其套用到該指" +"令的引數上。這是內部用於將 Python 回呼轉換成傳遞給 Tk 選項(如 *command*)的" +"指令名稱的機制。除非 *needcleanup* 為假值,否則當元件被銷毀時,該指令會自動被" +"刪除。" #: ../../library/tkinter.rst:1143 msgid "The arguments passed to *func* are no longer converted to strings." -msgstr "" +msgstr "傳遞給 *func* 的引數不再被轉換為字串。" #: ../../library/tkinter.rst:1148 msgid "" "Delete the Tcl command named *name*, such as one previously returned by :" "meth:`register`." -msgstr "" +msgstr "刪除名為 *name* 的 Tcl 指令,例如先前由 :meth:`register` 回傳的指令。" #: ../../library/tkinter.rst:1153 msgid "Return the widget instance corresponding to the Tk pathname *name*." -msgstr "" +msgstr "回傳對應於 Tk 路徑名稱 *name* 的元件實例。" #: ../../library/tkinter.rst:1157 msgid "" @@ -2271,12 +2399,14 @@ msgid "" "registered under the name *interp*, and return its result. This is not " "available on all platforms." msgstr "" +"將 Tcl 指令 *cmd* 連同給定的 *args*,傳送給以名稱 *interp* 註冊的 Tcl 直譯" +"器,並回傳其結果。此功能並非在所有平台上都可用。" #: ../../library/tkinter.rst:1163 msgid "" "Destroy this widget and all of its descendant widgets, and delete the Tcl " "commands associated with them." -msgstr "" +msgstr "銷毀此元件及其所有子孫元件,並刪除與它們關聯的 Tcl 指令。" #: ../../library/tkinter.rst:1171 msgid "" @@ -2284,10 +2414,12 @@ msgid "" "siblings. If *aboveThis* is given, the widget is moved to be just above it " "in the stacking order instead." msgstr "" +"在堆疊順序中將此元件提升,使其繪製在其同層元件的最上方。如果給出了 " +"*aboveThis*,則會改將此元件移動到緊接在其之上的堆疊順序位置。" #: ../../library/tkinter.rst:1176 msgid ":meth:`lift` is an alias of :meth:`!tkraise`." -msgstr "" +msgstr ":meth:`lift` 是 :meth:`!tkraise` 的別名。" #: ../../library/tkinter.rst:1180 msgid "" @@ -2295,27 +2427,33 @@ msgid "" "siblings. If *belowThis* is given, the widget is moved to be just below it " "in the stacking order instead." msgstr "" +"在堆疊順序中將此元件降低,使其繪製在其同層元件的下方。如果給出了 " +"*belowThis*,則會改將此元件移動到緊接在其之下的堆疊順序位置。" #: ../../library/tkinter.rst:1185 msgid "" ":meth:`tkraise`/:meth:`lift` and :meth:`lower` are overridden by the :class:" "`Canvas` widget, where they restack canvas items instead." msgstr "" +":meth:`tkraise`\\ /\\ :meth:`lift` 和 :meth:`lower` 在 :class:`Canvas` 元件中" +"被覆寫,改為重新排列畫布項目的堆疊順序。" #: ../../library/tkinter.rst:1191 msgid "" "Return the names of all images that currently exist in the Tcl interpreter." -msgstr "" +msgstr "回傳目前存在於 Tcl 直譯器中的所有圖片名稱。" #: ../../library/tkinter.rst:1194 msgid "" "This is overridden by the :class:`Text` widget, where :meth:`!image_names` " "returns the names of its embedded images instead." msgstr "" +"此方法在 :class:`Text` 元件中被覆寫,其 :meth:`!image_names` 改為回傳其嵌入圖" +"片的名稱。" #: ../../library/tkinter.rst:1200 msgid "Return the available image types, such as ``'photo'`` and ``'bitmap'``." -msgstr "" +msgstr "回傳可用的圖片型別,例如 ``'photo'`` 和 ``'bitmap'``。" #: ../../library/tkinter.rst:1207 msgid "" @@ -2325,10 +2463,13 @@ msgid "" "(the default) or ``'center'``. Called with no argument, this method has no " "effect." msgstr "" +"設定錨點,控制當容器大於格線,且沒有任何列或欄具有非零權重時,格線在此容器內" +"的放置位置。*anchor* 是慣用的錨點字串之一,例如 ``'nw'``\\ (預設值)或 " +"``'center'``。若不帶引數呼叫,此方法沒有作用。" #: ../../library/tkinter.rst:1214 msgid ":meth:`anchor` is an alias of :meth:`!grid_anchor`." -msgstr "" +msgstr ":meth:`anchor` 是 :meth:`!grid_anchor` 的別名。" #: ../../library/tkinter.rst:1223 msgid "" @@ -2339,6 +2480,11 @@ msgid "" "cell; if *col2* and *row2* are also given, it spans from the cell (*column*, " "*row*) to the cell (*col2*, *row2*)." msgstr "" +"以像素為單位,回傳此容器中格線佈局某個區域的邊界框,形式為一個 4 元素 tuple " +"``(xoffset, yoffset, width, height)``。若不帶引數,則回傳整個格線的邊界框。如" +"果給出了 *column* 和 *row*,該框會從第 0 列第 0 欄的儲存格延伸到該儲存格;如" +"果還給出了 *col2* 和 *row2*,則會從儲存格 (*column*, *row*) 延伸到儲存格 " +"(*col2*, *row2*)。" #: ../../library/tkinter.rst:1230 msgid "" @@ -2347,6 +2493,10 @@ msgid "" "ttk.Entry>` and :class:`ttk.Treeview `, which provide " "their own :meth:`!bbox` method." msgstr "" +":meth:`bbox` 是 :meth:`!grid_bbox` 的別名,但 :class:`Canvas`、:class:" +"`Listbox`、:class:`Spinbox`、:class:`Text`、:class:`ttk.Entry ` 和 :class:`ttk.Treeview ` 除外,它們提供了自己" +"的 :meth:`!bbox` 方法。" #: ../../library/tkinter.rst:1241 msgid "" @@ -2356,14 +2506,17 @@ msgid "" "affect every column, or a child widget whose occupied columns are affected. " "The supported options are:" msgstr "" +"查詢或設定此容器所管理格線中欄(或多欄)*index* 的屬性。*index* 可以是一個欄" +"編號;在設定選項時,它也可以是一個欄編號的串列、字串 ``'all'``\\ (表示影響每" +"一欄),或一個子元件(表示影響其所占用的欄)。支援的選項有:" #: ../../library/tkinter.rst:1248 msgid "*minsize*" -msgstr "" +msgstr "*minsize*" #: ../../library/tkinter.rst:1249 msgid "The column's minimum size, in pixels." -msgstr "" +msgstr "該欄的最小尺寸,以像素為單位。" #: ../../library/tkinter.rst:1251 msgid "*weight*" @@ -2375,36 +2528,41 @@ msgid "" "A weight of ``0`` keeps the column at its requested size, and a column of " "weight two grows twice as fast as a column of weight one." msgstr "" +"一個整數,設定多餘空間要分配給該欄多少比例。權重為 ``0`` 會讓該欄維持其要求的" +"大小,權重為 2 的欄的成長速度會是權重為 1 的欄的兩倍。" #: ../../library/tkinter.rst:1257 msgid "*uniform*" -msgstr "" +msgstr "*uniform*" #: ../../library/tkinter.rst:1258 msgid "" "The name of a uniform group. Columns sharing a non-empty group name are kept " "in sizes that are strictly proportional to their weights." msgstr "" +"統一群組的名稱。共享相同非空群組名稱的欄,其大小會嚴格按照其權重成比例保持。" #: ../../library/tkinter.rst:1262 msgid "*pad*" -msgstr "" +msgstr "*pad*" #: ../../library/tkinter.rst:1263 msgid "" "Extra space, in pixels, added to the largest widget in the column when " "computing the column's size." -msgstr "" +msgstr "在計算欄的大小時,加到該欄中最大元件上的額外空間,以像素為單位。" #: ../../library/tkinter.rst:1266 msgid "" "With a single option name, return that option's value; with no options, " "return a dictionary of all of them." msgstr "" +"若給出單一選項名稱,則回傳該選項的值;若不給出任何選項,則回傳所有選項組成的" +"字典。" #: ../../library/tkinter.rst:1269 msgid ":meth:`columnconfigure` is an alias of :meth:`!grid_columnconfigure`." -msgstr "" +msgstr ":meth:`columnconfigure` 是 :meth:`!grid_columnconfigure` 的別名。" #: ../../library/tkinter.rst:1276 msgid "" @@ -2413,10 +2571,13 @@ msgid "" "`grid_columnconfigure`, and the supported options (*minsize*, *weight*, " "*uniform* and *pad*) are the same, applied to a row instead of a column." msgstr "" +"查詢或設定此容器所管理格線中列(或多列)*index* 的屬性。*index* 的解釋方式" +"與 :meth:`grid_columnconfigure` 相同,支援的選項(*minsize*、*weight*、" +"*uniform* 和 *pad*)也相同,只是套用於列而非欄。" #: ../../library/tkinter.rst:1282 msgid ":meth:`rowconfigure` is an alias of :meth:`!grid_rowconfigure`." -msgstr "" +msgstr ":meth:`rowconfigure` 是 :meth:`!grid_rowconfigure` 的別名。" #: ../../library/tkinter.rst:1286 msgid "" @@ -2425,6 +2586,8 @@ msgid "" "locations above or to the left of the grid, ``-1`` is returned for the " "corresponding coordinate." msgstr "" +"回傳包含位置 (*x*, *y*)(以相對於此容器的像素給出)的格線儲存格之 ``(column, " +"row)``。對於格線上方或左方的位置,對應的座標會回傳 ``-1``。" #: ../../library/tkinter.rst:1294 msgid "" @@ -2434,18 +2597,23 @@ msgid "" "is false, its size is left under your control. Called with no argument, " "return the current setting as a boolean." msgstr "" +"當此容器使用 grid 佈局管理器管理其子元件時,啟用或停用佈局傳播。當 *flag* 為" +"真時,容器會調整自身大小以符合其子元件要求的大小;當為假時,其大小則由你自行" +"控制。若不帶引數呼叫,則以布林值回傳目前的設定。" #: ../../library/tkinter.rst:1306 msgid "" "Return the size of the grid managed by this container as a ``(columns, " "rows)`` tuple." -msgstr "" +msgstr "以 ``(columns, rows)`` tuple 的形式,回傳此容器所管理格線的大小。" #: ../../library/tkinter.rst:1309 msgid "" ":meth:`size` is an alias of :meth:`!grid_size`, except on the :class:" "`Listbox` widget, which provides its own :meth:`!size` method." msgstr "" +":meth:`size` 是 :meth:`!grid_size` 的別名,但 :class:`Listbox` 元件除外,它提" +"供了自己的 :meth:`!size` 方法。" #: ../../library/tkinter.rst:1315 msgid "" @@ -2453,6 +2621,8 @@ msgid "" "recently managed first. If *row* or *column* is given, only the children in " "that row or column are returned." msgstr "" +"回傳此容器格線中所管理子元件的串列,最近被管理的排在最前面。如果給出了 *row* " +"或 *column*,則只回傳該列或該欄中的子元件。" #: ../../library/tkinter.rst:1327 msgid "" @@ -2462,31 +2632,34 @@ msgid "" "is false, its size is left under your control. Called with no argument, " "return the current setting as a boolean." msgstr "" +"當此容器使用 pack 佈局管理器管理其子元件時,啟用或停用佈局傳播。當 *flag* 為" +"真時,容器會調整自身大小以符合其子元件要求的大小;當為假時,其大小則由你自行" +"控制。若不帶引數呼叫,則以布林值回傳目前的設定。" #: ../../library/tkinter.rst:1334 msgid ":meth:`propagate` is an alias of :meth:`!pack_propagate`." -msgstr "" +msgstr ":meth:`propagate` 是 :meth:`!pack_propagate` 的別名。" #: ../../library/tkinter.rst:1341 msgid "" "Return a list of the child widgets managed by this container with the pack " "geometry manager, in packing order." -msgstr "" +msgstr "以 packing 的順序,回傳此容器透過 pack 佈局管理器所管理子元件的串列。" #: ../../library/tkinter.rst:1344 msgid ":meth:`slaves` is an alias of :meth:`!pack_slaves`." -msgstr "" +msgstr ":meth:`slaves` 是 :meth:`!pack_slaves` 的別名。" #: ../../library/tkinter.rst:1348 msgid "" "Return a list of the child widgets managed by this container with the place " "geometry manager." -msgstr "" +msgstr "回傳此容器透過 place 佈局管理器所管理子元件的串列。" #: ../../library/tkinter.rst:1353 msgid "" "Bind the event pattern *sequence* on this widget to the callable *func*." -msgstr "" +msgstr "將此元件上的事件模式 *sequence* 繫結到可呼叫物件 *func*。" #: ../../library/tkinter.rst:1355 msgid "" @@ -2497,6 +2670,10 @@ msgid "" "if *func* returns the string ``'break'``, no further bindings for the event " "are invoked." msgstr "" +"*sequence* 是一個事件模式,例如 ``''``\\ (滑鼠點擊)或 " +"``''``,也可以是數個必須在短時間內接連發生的此類模式的串接。當事" +"件發生時,會以描述該事件的 :class:`Event` 實例作為唯一引數呼叫 *func*;如果 " +"*func* 回傳字串 ``'break'``,則不會再呼叫該事件的其他繫結。" #: ../../library/tkinter.rst:1362 msgid "" @@ -2504,6 +2681,8 @@ msgid "" "*sequence*; otherwise it replaces them. The binding applies only to this " "widget." msgstr "" +"如果 *add* 為真,*func* 會被新增到已繫結到 *sequence* 的函式中;否則它會取代" +"它們。此繫結僅適用於此元件。" #: ../../library/tkinter.rst:1366 msgid "" @@ -2511,6 +2690,8 @@ msgid "" "passed to :meth:`unbind` to remove the binding without leaking the " "associated Tcl command." msgstr "" +":meth:`!bind` 會回傳一個字串識別碼(*funcid*),之後可以將其傳遞給 :meth:" +"`unbind`,以移除該繫結而不會洩漏相關聯的 Tcl 指令。" #: ../../library/tkinter.rst:1370 msgid "" @@ -2518,6 +2699,8 @@ msgid "" "*sequence*; if *sequence* is also omitted, return a list of all the " "sequences for which bindings exist on this widget." msgstr "" +"如果省略 *func*,則回傳目前與 *sequence* 關聯的繫結;如果同時省略 " +"*sequence*,則回傳此元件上所有存在繫結的事件序列串列。" #: ../../library/tkinter.rst:1376 msgid "" @@ -2528,20 +2711,26 @@ msgid "" "The set of binding tags for a widget can be inspected and changed with :meth:" "`bindtags`." msgstr "" +"與 :meth:`bind` 類似,但將 *func* 繫結到繫結標籤 *className*,而不是單一元" +"件,使該繫結適用於具有該標籤的每個元件。*className* 通常是元件類別的名稱,例" +"如 ``'Button'``,此時該繫結會影響該類別的所有元件。可以使用 :meth:`bindtags` " +"檢查和變更元件的繫結標籤集合。" #: ../../library/tkinter.rst:1384 ../../library/tkinter.rst:1391 msgid "The remaining arguments and the return value are as for :meth:`bind`." -msgstr "" +msgstr "其餘的引數和回傳值與 :meth:`bind` 相同。" #: ../../library/tkinter.rst:1388 msgid "" "Like :meth:`bind`, but bind *func* to the special binding tag ``'all'``, so " "that the binding applies to every widget in the application." msgstr "" +"與 :meth:`bind` 類似,但將 *func* 繫結到特殊的繫結標籤 ``'all'``,使該繫結適" +"用於應用程式中的每個元件。" #: ../../library/tkinter.rst:1395 msgid "Remove bindings for the event pattern *sequence* on this widget." -msgstr "" +msgstr "移除此元件上事件模式 *sequence* 的繫結。" #: ../../library/tkinter.rst:1397 msgid "" @@ -2550,24 +2739,33 @@ msgid "" "command is deleted. Otherwise all bindings for *sequence* are destroyed, " "leaving it unbound." msgstr "" +"如果給出了 *funcid*,則只會移除由它識別的函式(先前呼叫 :meth:`bind` 所回傳的" +"值),並刪除其相關聯的 Tcl 指令。否則,*sequence* 的所有繫結都會被銷毀,使其" +"變為未繫結狀態。" #: ../../library/tkinter.rst:1402 msgid "" "If *funcid* is given, only that callback is unbound; other callbacks bound " "to *sequence* are kept." msgstr "" +"如果給出了 *funcid*,則只會解除該回呼的繫結;其他繫結到 *sequence* 的回呼會被" +"保留。" #: ../../library/tkinter.rst:1409 msgid "" "Remove all bindings for the event pattern *sequence* from the binding tag " "*className*. See :meth:`bind_class`." msgstr "" +"從繫結標籤 *className* 中移除事件模式 *sequence* 的所有繫結。請參閱 :meth:" +"`bind_class`。" #: ../../library/tkinter.rst:1415 msgid "" "Remove all bindings for the event pattern *sequence* from the special " "binding tag ``'all'``. See :meth:`bind_all`." msgstr "" +"從特殊繫結標籤 ``'all'`` 中移除事件模式 *sequence* 的所有繫結。請參閱 :meth:" +"`bind_all`。" #: ../../library/tkinter.rst:1421 msgid "" @@ -2578,6 +2776,10 @@ msgid "" "pathname, its widget class, the pathname of its nearest toplevel ancestor, " "and ``'all'``, in that order." msgstr "" +"如果省略 *tagList*,則回傳與此元件關聯的繫結標籤 tuple。當元件上發生事件時," +"會依序套用到該元件的每個繫結標籤,並針對每個標籤執行最符合的繫結。預設情況" +"下,一個元件有四個繫結標籤:它自己的路徑名稱、它的元件類別、其最近的頂層祖先" +"的路徑名稱,以及 ``'all'``,順序如上所述。" #: ../../library/tkinter.rst:1430 msgid "" @@ -2585,12 +2787,14 @@ msgid "" "binding tags are set to its elements, which determines the order in which " "bindings are evaluated." msgstr "" +"如果給出了 *tagList*,它必須是一個字串序列;元件的繫結標籤會被設定為其元素," +"這決定了繫結被評估的順序。" #: ../../library/tkinter.rst:1434 msgid "" "The methods with the ``event_`` prefix define virtual events and generate " "events programmatically." -msgstr "" +msgstr "帶有 ``event_`` 前綴的方法用於定義虛擬事件,以及以程式化方式產生事件。" #: ../../library/tkinter.rst:1439 msgid "" @@ -2600,6 +2804,9 @@ msgid "" "If *virtual* is already defined, the new sequences are added to its existing " "ones." msgstr "" +"將名稱形式為 ``'<>'`` 的虛擬事件 *virtual*,與由 *sequences* 給出的每" +"個實體事件模式建立關聯,使虛擬事件在其中任何一個發生時都會觸發。如果 " +"*virtual* 已經被定義,則新的事件序列會被新增到其現有的序列中。" #: ../../library/tkinter.rst:1448 msgid "" @@ -2608,6 +2815,9 @@ msgid "" "ignored. If no *sequences* are given, all physical event sequences are " "removed, so that *virtual* no longer triggers." msgstr "" +"從與虛擬事件 *virtual* 關聯的事件序列中移除 *sequences* 中的每一個。目前未與 " +"*virtual* 關聯的序列會被忽略。如果沒有給出 *sequences*,則會移除所有實體事件" +"序列,使 *virtual* 不再觸發。" #: ../../library/tkinter.rst:1456 msgid "" @@ -2619,6 +2829,11 @@ msgid "" "control when the event is processed; refer to the Tk ``event`` manual page " "for the full list." msgstr "" +"在此元件上產生事件 *sequence*,並安排將其處理得如同它來自視窗系統一般。" +"*sequence* 必須是單一事件模式,例如 ``''`` 或 ``'<>'``,而不" +"是數個模式的串接。關鍵字引數用於指定事件的其他欄位,例如以 *x* 和 *y* 表示指" +"標位置,或以 *when* 控制事件何時被處理;完整清單請參閱 Tk 的 ``event`` 手冊頁" +"面。" #: ../../library/tkinter.rst:1466 msgid "" @@ -2627,12 +2842,17 @@ msgid "" "event sequences currently associated with it, or an empty tuple if it is not " "defined." msgstr "" +"如果省略 *virtual*,則回傳目前已定義的所有虛擬事件的 tuple。如果給出了 " +"*virtual*,則回傳目前與其關聯的實體事件序列 tuple,如果尚未定義,則回傳空 " +"tuple。" #: ../../library/tkinter.rst:1471 msgid "" "The methods with the ``after`` prefix schedule callbacks to run after a " "delay or when the application is idle." msgstr "" +"帶有 ``after`` 前綴的方法用於排程回呼,使其在延遲一段時間後或應用程式閒置時執" +"行。" #: ../../library/tkinter.rst:1476 msgid "" @@ -2640,20 +2860,25 @@ msgid "" "*args* and *kw* passed to it as positional and keyword arguments. Return an " "identifier that can be passed to :meth:`after_cancel` to cancel the call." msgstr "" +"排程在 *ms* 毫秒後呼叫可呼叫物件 *func*,並將 *args* 和 *kw* 作為位置引數和關" +"鍵字引數傳遞給它。回傳一個識別碼,可將其傳遞給 :meth:`after_cancel` 以取消該" +"次呼叫。" #: ../../library/tkinter.rst:1481 msgid "" "If *func* is omitted, sleep for *ms* milliseconds instead, processing no " "events during that time, and return ``None``." msgstr "" +"如果省略 *func*,則改為休眠 *ms* 毫秒,在此期間不處理任何事件,並回傳 " +"``None``。" #: ../../library/tkinter.rst:1484 msgid "*func* can now be any callable object, not only a function." -msgstr "" +msgstr "*func* 現在可以是任何可呼叫物件,而不僅限於函式。" #: ../../library/tkinter.rst:1487 ../../library/tkinter.rst:1512 msgid "Keyword arguments are now passed to *func*." -msgstr "" +msgstr "關鍵字引數現在會被傳遞給 *func*。" #: ../../library/tkinter.rst:1493 msgid "" @@ -2662,11 +2887,15 @@ msgid "" "passing a value that is not such an identifier raises :exc:`ValueError`. If " "the callback has already run or been cancelled, this has no effect." msgstr "" +"取消先前透過 :meth:`after` 或 :meth:`after_idle` 排程的回呼。*id* 必須是這些" +"方法之一所回傳的識別碼;傳入非此類識別碼的值會引發 :exc:`ValueError`。如果該" +"回呼已經執行過或已被取消,此方法不會有任何作用。" #: ../../library/tkinter.rst:1499 msgid "" "Passing ``None`` (or any false value) as *id* now raises :exc:`ValueError`." msgstr "" +"現在,將 ``None``\\ (或任何假值)作為 *id* 傳入會引發 :exc:`ValueError`。" #: ../../library/tkinter.rst:1506 msgid "" @@ -2675,6 +2904,9 @@ msgid "" "events to process. Return an identifier that can be passed to :meth:" "`after_cancel` to cancel the call." msgstr "" +"排程在 Tk 主迴圈下一次變為閒置時(即它沒有其他事件需要處理時),呼叫可呼叫物" +"件 *func*,並將 *args* 和 *kw* 傳遞給它。回傳一個識別碼,可將其傳遞給 :meth:" +"`after_cancel` 以取消該次呼叫。" #: ../../library/tkinter.rst:1518 msgid "" @@ -2682,6 +2914,8 @@ msgid "" "currently scheduled with :meth:`after` and :meth:`after_idle` for this " "interpreter." msgstr "" +"如果省略 *id*,則回傳目前透過 :meth:`after` 和 :meth:`after_idle` 為此直譯器" +"排程的所有回呼識別碼組成的 tuple。" #: ../../library/tkinter.rst:1522 msgid "" @@ -2690,6 +2924,9 @@ msgid "" "*script* refers to the function to be called and *type* is either ``'idle'`` " "or ``'timer'``. A :exc:`TclError` is raised if *id* does not exist." msgstr "" +"如果給出了 *id*,它必須識別一個尚未執行或尚未被取消的回呼,回傳值是一個 " +"tuple ``(script, type)``,其中 *script* 指向要被呼叫的函式,*type* 則是 " +"``'idle'`` 或 ``'timer'`` 之一。如果 *id* 不存在,則會引發 :exc:`TclError`。" #: ../../library/tkinter.rst:1533 msgid "" @@ -2697,10 +2934,12 @@ msgid "" "destroyed. This is normally called once, on the root window, to run the " "application." msgstr "" +"進入 Tk 事件迴圈,處理事件直到所有視窗都被銷毀為止。通常會在根視窗上呼叫一次" +"此方法,以執行應用程式。" #: ../../library/tkinter.rst:1539 msgid "Quit the Tcl interpreter, causing :meth:`mainloop` to return." -msgstr "" +msgstr "結束 Tcl 直譯器,使 :meth:`mainloop` 回傳。" #: ../../library/tkinter.rst:1543 msgid "" @@ -2708,6 +2947,8 @@ msgid "" "have been processed. This brings the display up to date and handles any " "events that are already queued, then returns." msgstr "" +"進入事件迴圈,直到所有待處理的事件(包括閒置回呼)都已處理完畢。此方法會更新" +"顯示畫面並處理任何已經排入佇列的事件,然後回傳。" #: ../../library/tkinter.rst:1550 msgid "" @@ -2715,6 +2956,8 @@ msgid "" "updates the display of windows, for example after geometry changes, but does " "not process events caused by the user." msgstr "" +"進入事件迴圈,直到所有待處理的閒置回呼都已被呼叫。此方法會更新視窗的顯示,例" +"如在佈局變更之後,但不會處理由使用者引起的事件。" #: ../../library/tkinter.rst:1559 msgid "" @@ -2723,10 +2966,13 @@ msgid "" "a :class:`Variable` instance, such as an :class:`IntVar` or :class:" "`StringVar`." msgstr "" +"等待直到 Tcl 變數 *name* 被修改,期間會持續處理事件,使應用程式保持回應。" +"*name* 通常是一個 :class:`Variable` 實例,例如 :class:`IntVar` 或 :class:" +"`StringVar`。" #: ../../library/tkinter.rst:1564 msgid ":meth:`waitvar` is an alias of :meth:`!wait_variable`." -msgstr "" +msgstr ":meth:`waitvar` 是 :meth:`!wait_variable` 的別名。" #: ../../library/tkinter.rst:1568 msgid "" @@ -2734,6 +2980,8 @@ msgid "" "meantime. If *window* is omitted, this widget is used. This is typically " "used to wait for the user to finish interacting with a dialog box." msgstr "" +"等待直到 *window* 被銷毀,期間會持續處理事件。如果省略 *window*,則使用此元" +"件。這通常用於等待使用者完成與對話方塊的互動。" #: ../../library/tkinter.rst:1576 msgid "" @@ -2742,10 +2990,13 @@ msgid "" "If *window* is omitted, this widget is used. This is typically used to wait " "for a newly created window to become visible before acting on it." msgstr "" +"等待直到 *window* 的可見性狀態發生變化,例如它首次出現在螢幕上時,期間會持續" +"處理事件。如果省略 *window*,則使用此元件。這通常用於在對新建立的視窗進行操作" +"之前,等待它變為可見。" #: ../../library/tkinter.rst:1583 msgid "The methods with the ``focus_`` prefix manage the keyboard focus." -msgstr "" +msgstr "帶有 ``focus_`` 前綴的方法用於管理鍵盤焦點。" #: ../../library/tkinter.rst:1590 msgid "" @@ -2757,6 +3008,11 @@ msgid "" "except on the :class:`Canvas` and :class:`ttk.Treeview ` widgets, which provide their own :meth:`!focus` method." msgstr "" +"將此元件所在顯示器的鍵盤輸入焦點導向此元件。如果應用程式目前在此元件所在的顯" +"示器上沒有輸入焦點,則此元件會被記住為其頂層視窗的焦點視窗,並在視窗管理器下" +"次將焦點給予該頂層視窗時,把焦點重新導向到它。:meth:`focus` 是 :meth:`!" +"focus_set` 的別名,但 :class:`Canvas` 和 :class:`ttk.Treeview ` 元件除外,它們提供了自己的 :meth:`!focus` 方法。" #: ../../library/tkinter.rst:1602 msgid "" @@ -2765,6 +3021,9 @@ msgid "" "should be used sparingly, if at all; normally an application should wait for " "the window manager to give it the focus rather than claiming it." msgstr "" +"即使應用程式目前在此元件所在的顯示器上沒有輸入焦點,也將鍵盤輸入焦點導向此元" +"件。應謹慎使用此方法,甚至盡量避免使用;通常應用程式應該等待視窗管理器賦予其" +"焦點,而不是主動取得焦點。" #: ../../library/tkinter.rst:1610 msgid "" @@ -2772,6 +3031,8 @@ msgid "" "or ``None`` if no widget in the application has the focus. Use :meth:" "`focus_displayof` to work correctly with several displays." msgstr "" +"回傳目前在應用程式中擁有鍵盤焦點的元件,如果應用程式中沒有任何元件擁有焦點," +"則回傳 ``None``。若要在多個顯示器下正確運作,請使用 :meth:`focus_displayof`。" #: ../../library/tkinter.rst:1616 msgid "" @@ -2779,6 +3040,8 @@ msgid "" "this widget is located, or ``None`` if no widget in the application has the " "focus on that display." msgstr "" +"回傳目前在此元件所在顯示器上擁有鍵盤焦點的元件,如果應用程式中沒有任何元件在" +"該顯示器上擁有焦點,則回傳 ``None``。" #: ../../library/tkinter.rst:1622 msgid "" @@ -2788,6 +3051,9 @@ msgid "" "top level. If no widget in that top level has ever had the focus, or if the " "most recent focus widget has been deleted, the top level itself is returned." msgstr "" +"回傳與此元件位於同一頂層視窗的所有元件中,最近曾擁有鍵盤焦點的元件;這是視窗" +"管理器下次將焦點給予該頂層視窗時,將會接收焦點的元件。如果該頂層視窗中沒有任" +"何元件曾經擁有焦點,或者最近擁有焦點的元件已被刪除,則會回傳該頂層視窗本身。" #: ../../library/tkinter.rst:1631 msgid "" @@ -2795,6 +3061,8 @@ msgid "" "widget whenever the mouse pointer enters it. This cannot easily be disabled " "once enabled." msgstr "" +"重新設定 Tk 以使用隱含的焦點模型,即每當滑鼠指標進入某個元件時,焦點就會被設" +"定到該元件。一旦啟用,就無法輕易停用。" #: ../../library/tkinter.rst:1637 msgid "" @@ -2805,6 +3073,10 @@ msgid "" "option is set to ``0``. This method is used in the default bindings for the :" "kbd:`Tab` key." msgstr "" +"回傳鍵盤遍歷順序中,此元件之後的下一個元件,如果沒有則回傳 ``None``。遍歷順序" +"首先前往下一個子元件,然後遞迴前往該子元件的子元件,接著前往堆疊順序中較高的" +"下一個同層元件。如果一個元件的 ``takefocus`` 選項設為 ``0``,則會跳過該元件。" +"此方法用於 :kbd:`Tab` 鍵的預設繫結中。" #: ../../library/tkinter.rst:1647 msgid "" @@ -2813,12 +3085,17 @@ msgid "" "defined. This method is used in the default bindings for the :kbd:`Shift-" "Tab` key." msgstr "" +"回傳鍵盤遍歷順序中,此元件之前的上一個元件,如果沒有則回傳 ``None``。關於順序" +"如何定義,請參閱 :meth:`tk_focusNext`。此方法用於 :kbd:`Shift-Tab` 鍵的預設繫" +"結中。" #: ../../library/tkinter.rst:1652 msgid "" "The methods with the ``grab_`` prefix set and query the input grab, which " "directs all input events to a single widget." msgstr "" +"帶有 ``grab_`` 前綴的方法用於設定和查詢輸入捕獲(grab),它會將所有輸入事件導" +"向單一元件。" #: ../../library/tkinter.rst:1657 msgid "" @@ -2832,6 +3109,12 @@ msgid "" "modal: while the grab is in effect the user cannot interact with the other " "windows of the application." msgstr "" +"在此元件上設定一個區域捕獲(local grab)。捕獲會將指標事件限制在此元件及其子" +"孫元件之內:當指標位於此元件子樹之外時,按鍵按下和放開以及指標移動都會回報給" +"捕獲該元件,而子樹之外的視窗會變得無法感應輸入,直到捕獲被釋放為止。區域捕獲" +"只會影響進行捕獲的應用程式本身。此應用程式先前在此元件所在顯示器上設定的任何" +"捕獲都會被自動釋放。設定捕獲是讓對話方塊變為強制回應(modal)的常見方式:在捕" +"獲有效期間,使用者無法與應用程式的其他視窗互動。" #: ../../library/tkinter.rst:1671 msgid "" @@ -2842,28 +3125,36 @@ msgid "" "unusable with a global grab, since other applications stop receiving events " "until it is released." msgstr "" +"在此元件上設定一個全域捕獲(global grab)。全域捕獲類似於 :meth:`grab_set` 所" +"設定的區域捕獲,但它會鎖定螢幕上所有其他應用程式,使得只有此元件的子樹能感應" +"指標事件,同時它也會捕獲鍵盤。請謹慎使用:全域捕獲很容易讓顯示器變得無法使" +"用,因為其他應用程式在捕獲被釋放之前都會停止接收事件。" #: ../../library/tkinter.rst:1682 msgid "Release the grab on this widget if there is one; otherwise do nothing." -msgstr "" +msgstr "如果此元件上有捕獲,則將其釋放;否則不做任何事。" #: ../../library/tkinter.rst:1686 msgid "" "Return the widget that currently holds the grab in this application for this " "widget's display, or ``None`` if there is no such widget." msgstr "" +"回傳目前在此應用程式中,為此元件所在顯示器持有捕獲的元件,如果沒有這樣的元" +"件,則回傳 ``None``。" #: ../../library/tkinter.rst:1691 msgid "" "Return ``None`` if no grab is currently set on this widget, ``\"local\"`` if " "a local grab is set, or ``\"global\"`` if a global grab is set." msgstr "" +"如果此元件目前沒有設定捕獲,則回傳 ``None``;如果設定了區域捕獲,則回傳 " +"``\"local\"``;如果設定了全域捕獲,則回傳 ``\"global\"``。" #: ../../library/tkinter.rst:1694 msgid "" "The methods with the ``selection_`` prefix retrieve and manage the X " "selection." -msgstr "" +msgstr "帶有 ``selection_`` 前綴的方法用於取得和管理 X 選取範圍(selection)。" #: ../../library/tkinter.rst:1699 msgid "" @@ -2873,6 +3164,10 @@ msgid "" "*displayof* keyword argument names a widget that determines the display on " "which to operate, and defaults to this widget." msgstr "" +"清除 X 選取範圍,使其不再被任何視窗擁有。要清除的選取範圍由關鍵字引數 " +"*selection* 給定,這是一個 atom 名稱,例如 ``'PRIMARY'`` 或 ``'CLIPBOARD'``;" +"預設為 ``PRIMARY``。關鍵字引數 *displayof* 用於指名一個元件,決定要在哪個顯示" +"器上操作,預設為此元件。" #: ../../library/tkinter.rst:1706 msgid "" @@ -2880,6 +3175,8 @@ msgid "" "`Spinbox` widgets, where :meth:`!selection_clear` clears the widget's own " "selection instead." msgstr "" +"此方法在 :class:`Entry`、:class:`Listbox` 和 :class:`Spinbox` 元件中被覆寫," +"其 :meth:`!selection_clear` 改為清除元件自身的選取範圍。" #: ../../library/tkinter.rst:1712 msgid "" @@ -2892,6 +3189,11 @@ msgid "" "*displayof* keyword argument names a widget that determines the display from " "which to retrieve the selection, and defaults to this widget." msgstr "" +"回傳目前 X 選取範圍的內容。關鍵字引數 *selection* 用於指名選取範圍,預設為 " +"``PRIMARY``。關鍵字引數 *type* 指定資料要以何種形式回傳(期望的轉換目標),這" +"是一個 atom 名稱,例如 ``'STRING'`` 或 ``'FILE_NAME'``;預設為 ``STRING``,但" +"在 X11 上會先嘗試 ``UTF8_STRING``,並以 ``STRING`` 作為備援。關鍵字引數 " +"*displayof* 用於指名一個元件,決定要從哪個顯示器取得選取範圍,預設為此元件。" #: ../../library/tkinter.rst:1726 msgid "" @@ -2905,6 +3207,12 @@ msgid "" "keyword argument *type* gives the form of the selection that the handler " "supplies (such as ``'STRING'`` or ``'FILE_NAME'``, default ``STRING``)." msgstr "" +"將 *command* 註冊為處理常式,用於在其他應用程式請求時,提供由此元件擁有的 X " +"選取範圍。當選取範圍被取得時,會以兩個引數呼叫 *command*:起始字元偏移量和要" +"回傳的最大字元數,且它最多必須回傳從該偏移量開始的那麼多個選取範圍字元;對於" +"非常長的選取範圍,會以遞增的偏移量重複呼叫它。關鍵字引數 *selection* 用於指名" +"選取範圍(預設為 ``PRIMARY``),關鍵字引數 *type* 則給出處理常式所提供選取範" +"圍的形式(例如 ``'STRING'`` 或 ``'FILE_NAME'``,預設為 ``STRING``)。" #: ../../library/tkinter.rst:1740 msgid "" @@ -2912,6 +3220,9 @@ msgid "" "owner, if any, is notified that it has lost the selection. The keyword " "argument *selection* names the selection and defaults to ``PRIMARY``." msgstr "" +"使此元件成為其所在顯示器上 X 選取範圍的擁有者。先前的擁有者(如果有的話)會被" +"通知它已經失去了該選取範圍。關鍵字引數 *selection* 用於指名選取範圍,預設為 " +"``PRIMARY``。" #: ../../library/tkinter.rst:1747 msgid "" @@ -2921,10 +3232,14 @@ msgid "" "defaults to ``PRIMARY``. The *displayof* keyword argument names a widget " "that determines the display to query, and defaults to this widget." msgstr "" +"回傳此應用程式中,在包含此元件的顯示器上擁有 X 選取範圍的元件,如果此應用程式" +"中沒有任何元件擁有該選取範圍,則回傳 ``None``。關鍵字引數 *selection* 用於指" +"名選取範圍,預設為 ``PRIMARY``。關鍵字引數 *displayof* 用於指名一個元件,決定" +"要查詢哪個顯示器,預設為此元件。" #: ../../library/tkinter.rst:1755 msgid "The methods with the ``clipboard_`` prefix manage the clipboard." -msgstr "" +msgstr "帶有 ``clipboard_`` 前綴的方法用於管理剪貼簿。" #: ../../library/tkinter.rst:1759 msgid "" @@ -2939,6 +3254,13 @@ msgid "" "the target display, and defaults to this widget. The contents can be " "retrieved with :meth:`clipboard_get` or :meth:`selection_get`." msgstr "" +"將 *string* 附加到 Tk 剪貼簿,並在此元件所在的顯示器上取得剪貼簿的擁有權。在" +"附加之前,應先使用 :meth:`clipboard_clear` 清空剪貼簿;所有附加操作都應該在返" +"回事件迴圈之前完成,以確保剪貼簿以原子方式更新。關鍵字引數 *type* 指定資料的" +"形式,這是一個 atom 名稱,例如 ``'STRING'`` 或 ``'FILE_NAME'``\\ (預設為 " +"``STRING``),關鍵字引數 *format* 則指定用於傳輸它的表示法(預設為 " +"``STRING``)。關鍵字引數 *displayof* 用於指名一個元件,決定目標顯示器,預設為" +"此元件。內容可以使用 :meth:`clipboard_get` 或 :meth:`selection_get` 取得。" #: ../../library/tkinter.rst:1775 msgid "" @@ -2946,6 +3268,8 @@ msgid "" "previous contents. The *displayof* keyword argument names a widget that " "determines the target display, and defaults to this widget." msgstr "" +"在此元件所在的顯示器上取得剪貼簿的擁有權,並移除任何先前的內容。關鍵字引數 " +"*displayof* 用於指名一個元件,決定目標顯示器,預設為此元件。" #: ../../library/tkinter.rst:1782 msgid "" @@ -2957,12 +3281,17 @@ msgid "" "widget that determines the display, and defaults to the root window of the " "application. This is equivalent to ``selection_get(selection='CLIPBOARD')``." msgstr "" +"從此元件所在的顯示器上取得剪貼簿的資料。關鍵字引數 *type* 指定資料要以何種形" +"式回傳,這是一個 atom 名稱,例如 ``'STRING'`` 或 ``'FILE_NAME'``;預設為 " +"``STRING``,但在 X11 上會先嘗試 ``UTF8_STRING``,並以 ``STRING`` 作為備援。關" +"鍵字引數 *displayof* 用於指名一個元件,決定顯示器,預設為應用程式的根視窗。這" +"相當於 ``selection_get(selection='CLIPBOARD')``。" #: ../../library/tkinter.rst:1791 msgid "" "The methods with the ``option_`` prefix query and modify the Tk option " "database." -msgstr "" +msgstr "帶有 ``option_`` 前綴的方法用於查詢和修改 Tk 選項資料庫。" #: ../../library/tkinter.rst:1796 msgid "" @@ -2973,6 +3302,11 @@ msgid "" "(40), ``'userDefault'`` (60), or ``'interactive'`` (80); it defaults to " "``interactive``." msgstr "" +"在 Tk 選項資料庫中新增一個選項,將 *value* 與 *pattern* 建立關聯。*pattern* " +"由以星號或點號分隔的名稱和/或類別組成,採用一般的 X 格式。*priority* 是介於 " +"0 到 100 之間的整數,或是符號名稱 ``'widgetDefault'``\\ (20)、" +"``'startupFile'``\\ (40)、``'userDefault'``\\ (60)或 ``'interactive'``\\ " +"(80)之一;預設為 ``interactive``。" #: ../../library/tkinter.rst:1806 msgid "" @@ -2981,6 +3315,8 @@ msgid "" "automatically the next time an option is added to or removed from the " "database." msgstr "" +"清除 Tk 選項資料庫。下次向資料庫新增或移除選項時,來自 :envvar:`!" +"RESOURCE_MANAGER` 屬性或 :file:`.Xdefaults` 檔案的預設選項會被自動重新載入。" #: ../../library/tkinter.rst:1813 msgid "" @@ -2990,6 +3326,9 @@ msgid "" "priority is returned, and among entries of equal priority the most recently " "added one." msgstr "" +"從 Tk 選項資料庫中,回傳在 *name* 和 *className* 下與此元件相符的選項值,如果" +"沒有相符的項目,則回傳空字串。當有多個項目相符時,會回傳優先權最高的那一個;" +"在優先權相同的項目中,則回傳最近新增的那一個。" #: ../../library/tkinter.rst:1822 msgid "" @@ -2998,6 +3337,9 @@ msgid "" "specifies to the Tk option database. *priority* is interpreted as for :meth:" "`option_add` and defaults to ``interactive``." msgstr "" +"讀取名為 *fileName* 的檔案,該檔案應具有 X 資源資料庫的標準格式,例如 :file:" +"`.Xdefaults`,並將其指定的所有選項新增到 Tk 選項資料庫中。*priority* 的解釋方" +"式與 :meth:`option_add` 相同,預設為 ``interactive``。" #: ../../library/tkinter.rst:1830 msgid "" @@ -3006,6 +3348,9 @@ msgid "" "*displayof* is given as a widget, the bell is rung on that widget's display " "instead." msgstr "" +"在此元件所在的顯示器上響鈴,使用該顯示器目前與鈴聲相關的設定,並重設該螢幕的" +"螢幕保護程式。如果將 *displayof* 指定為一個元件,則改為在該元件所在的顯示器上" +"響鈴。" #: ../../library/tkinter.rst:1838 msgid "" @@ -3021,12 +3366,23 @@ msgid "" "``selectForeground``, and ``troughColor``; reasonable defaults are computed " "for any that are not specified." msgstr "" +"為所有 Tk 元件元素設定一個新的配色方案。現有的元件會被更新,且選項資料庫也會" +"被變更,使未來的元件使用新的顏色。單一顏色引數會被視為一般背景顏色,並依此計" +"算出一整套調色盤。或者,也可以將引數以關鍵字 *name*/*value* 對的形式給出,指" +"名選項資料庫中的個別選項。可辨識的選項名稱有 ``activeBackground``、" +"``activeForeground``、``background``、``disabledForeground``、" +"``foreground``、``highlightBackground``、``highlightColor``、" +"``insertBackground``、``selectColor``、``selectBackground``、" +"``selectForeground`` 和 ``troughColor``;對於未指定的選項,會計算出合理的預設" +"值。" #: ../../library/tkinter.rst:1854 msgid "" "Restore the application's colors to the light brown (bisque) color scheme " "used in Tk 3.6 and earlier versions. Provided for backward compatibility." msgstr "" +"將應用程式的顏色還原為 Tk 3.6 及更早版本中所使用的淺棕色(bisque)配色方案。" +"此方法為了向後相容而提供。" #: ../../library/tkinter.rst:1860 msgid "" @@ -3034,12 +3390,16 @@ msgid "" "true *boolean* value enables strict Motif compliance (for example, no color " "change when the mouse passes over a slider). Return the resulting setting." msgstr "" +"查詢或設定 Tk 的外觀和風格是否應嚴格遵循 Motif。真值的 *boolean* 會啟用嚴格" +"的 Motif 相容模式(例如,當滑鼠經過滑桿時不會變更顏色)。回傳結果設定。" #: ../../library/tkinter.rst:1865 msgid "" "The methods with the ``busy_`` prefix manage the busy state of a window, " "which shows a busy cursor and ignores user input." msgstr "" +"帶有 ``busy_`` 前綴的方法用於管理視窗的忙碌狀態,這會顯示忙碌游標並忽略使用者" +"輸入。" #: ../../library/tkinter.rst:1879 msgid "" @@ -3049,6 +3409,9 @@ msgid "" "`update` should be called immediately afterwards to ensure that the hold " "operation is in effect before the application starts its processing." msgstr "" +"使此元件顯示為忙碌狀態。一個透明視窗會被放置在此元件的前面,使其及其在元件階" +"層中的所有子孫元件都無法接收指標事件,並顯示忙碌游標。通常應在此之後立即呼" +"叫 :meth:`update`,以確保在應用程式開始處理之前,持有(hold)操作已經生效。" #: ../../library/tkinter.rst:1887 msgid "" @@ -3056,12 +3419,16 @@ msgid "" "displayed while the widget is busy; it may have any of the values accepted " "by :meth:`!configure`." msgstr "" +"唯一支援的設定選項是 *cursor*,即元件忙碌時要顯示的游標;它可以是 :meth:`!" +"configure` 所接受的任何值。" #: ../../library/tkinter.rst:1891 msgid "" ":meth:`busy_hold`, :meth:`busy` and :meth:`tk_busy` are aliases of :meth:`!" "tk_busy_hold`." msgstr "" +":meth:`busy_hold`、:meth:`busy` 和 :meth:`tk_busy` 是 :meth:`!tk_busy_hold` " +"的別名。" #: ../../library/tkinter.rst:1908 msgid "" @@ -3072,6 +3439,10 @@ msgid "" "Otherwise set the given options to the given values. Options may have any of " "the values accepted by :meth:`tk_busy_hold`." msgstr "" +"查詢或修改忙碌視窗的設定選項。該元件必須先前已透過 :meth:`tk_busy_hold` 被設" +"為忙碌狀態。若不帶引數,則回傳描述所有可用選項的字典;如果 *cnf* 是一個選項的" +"名稱,則回傳描述該選項的 tuple。否則,將給定的選項設定為給定的值。選項的值可" +"以是 :meth:`tk_busy_hold` 所接受的任何值。" #: ../../library/tkinter.rst:1916 msgid "" @@ -3079,18 +3450,24 @@ msgid "" "example, if a :class:`Frame` widget named ``frame`` is to be made busy, the " "busy cursor can be specified for it by either of the calls::" msgstr "" +"選項資料庫是透過元件名稱或類別來參照的。例如,如果要將名為 ``frame`` 的 :" +"class:`Frame` 元件設為忙碌狀態,可以透過以下任一呼叫來為其指定忙碌游標: ::" #: ../../library/tkinter.rst:1920 msgid "" "w.option_add('*frame.busyCursor', 'gumby')\n" "w.option_add('*Frame.BusyCursor', 'gumby')" msgstr "" +"w.option_add('*frame.busyCursor', 'gumby')\n" +"w.option_add('*Frame.BusyCursor', 'gumby')" #: ../../library/tkinter.rst:1923 msgid "" ":meth:`busy_configure`, :meth:`busy_config` and :meth:`tk_busy_config` are " "aliases of :meth:`!tk_busy_configure`." msgstr "" +":meth:`busy_configure`、:meth:`busy_config` 和 :meth:`tk_busy_config` 是 :" +"meth:`!tk_busy_configure` 的別名。" #: ../../library/tkinter.rst:1934 msgid "" @@ -3098,10 +3475,12 @@ msgid "" "have been previously made busy by :meth:`tk_busy_hold`, and *option* may " "have any of the values accepted by that method." msgstr "" +"回傳忙碌設定選項 *option* 目前的值。該元件必須先前已透過 :meth:" +"`tk_busy_hold` 被設為忙碌狀態,*option* 可以是該方法所接受的任何值。" #: ../../library/tkinter.rst:1938 msgid ":meth:`busy_cget` is an alias of :meth:`!tk_busy_cget`." -msgstr "" +msgstr ":meth:`busy_cget` 是 :meth:`!tk_busy_cget` 的別名。" #: ../../library/tkinter.rst:1948 msgid "" @@ -3110,34 +3489,38 @@ msgid "" "be received by the widget. These resources are also released when the widget " "is destroyed." msgstr "" +"使此元件不再處於忙碌狀態,釋放在其被設為忙碌狀態時所配置的資源(包括透明視" +"窗)。元件將再次接收使用者事件。當元件被銷毀時,這些資源也會被釋放。" #: ../../library/tkinter.rst:1953 msgid ":meth:`busy_forget` is an alias of :meth:`!tk_busy_forget`." -msgstr "" +msgstr ":meth:`busy_forget` 是 :meth:`!tk_busy_forget` 的別名。" #: ../../library/tkinter.rst:1963 msgid "Return ``True`` if the widget is currently busy, ``False`` otherwise." -msgstr "" +msgstr "如果元件目前為忙碌狀態則回傳 ``True``,否則回傳 ``False``。" #: ../../library/tkinter.rst:1965 msgid ":meth:`busy_status` is an alias of :meth:`!tk_busy_status`." -msgstr "" +msgstr ":meth:`busy_status` 是 :meth:`!tk_busy_status` 的別名。" #: ../../library/tkinter.rst:1975 msgid "" "Return a list of widgets that are currently busy. If *pattern* is given, " "only busy widgets whose path names match the pattern are returned." msgstr "" +"回傳目前為忙碌狀態的元件列表。如果有給定 *pattern*,則只會回傳路徑名稱與該模" +"式相符的忙碌元件。" #: ../../library/tkinter.rst:1979 msgid ":meth:`busy_current` is an alias of :meth:`!tk_busy_current`." -msgstr "" +msgstr ":meth:`busy_current` 是 :meth:`!tk_busy_current` 的別名。" #: ../../library/tkinter.rst:1983 msgid "" "The methods with the ``winfo_`` prefix retrieve information about windows " "managed by Tk." -msgstr "" +msgstr "帶有 ``winfo_`` 前綴的方法會取得由 Tk 管理的視窗的相關資訊。" #: ../../library/tkinter.rst:1988 msgid "" @@ -3146,6 +3529,9 @@ msgid "" "the display of that window; otherwise it is looked up on the display of the " "application's main window." msgstr "" +"回傳名稱為 *name* 的 atom 的整數識別碼,如果該 atom 不存在則會建立一個新的。" +"如果有給定 *displayof*,則會在該視窗所在的顯示器上查找該 atom;否則會在應用程" +"式主視窗所在的顯示器上查找。" #: ../../library/tkinter.rst:1996 msgid "" @@ -3154,10 +3540,13 @@ msgid "" "identifier is looked up on the display of that window; otherwise it is " "looked up on the display of the application's main window." msgstr "" +"回傳整數識別碼為 *id* 的 atom 的文字名稱。這與 :meth:`winfo_atom` 互為反向操" +"作。如果有給定 *displayof*,則會在該視窗所在的顯示器上查找該識別碼;否則會在" +"應用程式主視窗所在的顯示器上查找。" #: ../../library/tkinter.rst:2004 msgid "Return the number of cells in the colormap for the widget." -msgstr "" +msgstr "回傳元件的色彩對映表中的單元數量。" #: ../../library/tkinter.rst:2008 msgid "" @@ -3165,16 +3554,18 @@ msgid "" "stacking order from lowest to highest. Toplevel windows are returned as " "children of their logical parents." msgstr "" +"回傳一個列表,內容是元件的子元件,依由下到上的堆疊順序排列。頂層視窗會作為其" +"邏輯父元件的子元件被回傳。" #: ../../library/tkinter.rst:2014 msgid "Return the class name of the widget." -msgstr "" +msgstr "回傳元件的類別名稱。" #: ../../library/tkinter.rst:2018 msgid "" "Return ``True`` if the colormap for the widget is known to be full, " "``False`` otherwise." -msgstr "" +msgstr "如果元件的色彩對映表已知已滿則回傳 ``True``,否則回傳 ``False``。" #: ../../library/tkinter.rst:2023 msgid "" @@ -3184,14 +3575,17 @@ msgid "" "If *displayof* is given, the coordinates refer to the screen containing that " "window; otherwise they refer to the screen of the application's main window." msgstr "" +"回傳包含由 *rootX* 和 *rootY* 給定之點的元件,如果本應用程式中沒有視窗包含該" +"點則回傳 ``None``。座標是以根視窗座標系統中的螢幕單位表示。如果有給定 " +"*displayof*,座標會參照該視窗所在的螢幕;否則會參照應用程式主視窗所在的螢幕。" #: ../../library/tkinter.rst:2033 msgid "Return the depth of the widget, that is, the number of bits per pixel." -msgstr "" +msgstr "回傳元件的深度,也就是每個像素的位元數。" #: ../../library/tkinter.rst:2037 msgid "Return true if the widget exists, false otherwise." -msgstr "" +msgstr "如果元件存在則回傳 true,否則回傳 false。" #: ../../library/tkinter.rst:2041 msgid "" @@ -3200,6 +3594,9 @@ msgid "" "``\"1i\"``). The result may be fractional; for a rounded integer value use :" "meth:`winfo_pixels`." msgstr "" +"回傳一個浮點數值,表示元件中對應於螢幕距離 *number*\\ (例如 ``\"2.0c\"`` 或 " +"``\"1i\"``)的像素數。結果可能是小數;若要取得四捨五入後的整數值,請使用 :" +"meth:`winfo_pixels`。" #: ../../library/tkinter.rst:2049 msgid "" @@ -3207,6 +3604,7 @@ msgid "" "dimensions are in pixels. An offset can be negative; see :meth:`~Wm." "geometry`." msgstr "" +"回傳元件的 geometry,格式為 ``widthxheight+x+y``。所有維度單位皆為像素。" #: ../../library/tkinter.rst:2055 msgid "" @@ -3214,12 +3612,16 @@ msgid "" "its height is 1 pixel; it is eventually changed by a geometry manager. See " "also :meth:`winfo_reqheight`." msgstr "" +"回傳元件的高度(以像素為單位)。視窗剛建立時高度為 1 像素,之後會由佈局管理器" +"變更。另請參閱 :meth:`winfo_reqheight`。" #: ../../library/tkinter.rst:2062 msgid "" "Return a low-level platform-specific identifier for the widget. On Unix this " "is the X window identifier, and on Windows it is the window handle." msgstr "" +"回傳元件的低階、平台特定的識別碼。在 Unix 上這是 X 視窗識別碼,在 Windows 上" +"則是視窗控制代碼。" #: ../../library/tkinter.rst:2068 msgid "" @@ -3228,27 +3630,32 @@ msgid "" "the display of that window; otherwise it refers to the display of the " "application's main window." msgstr "" +"回傳一個元組,內容為目前為特定顯示器註冊的所有 Tcl 直譯器的名稱。如果有給定 " +"*displayof*,回傳值會參照該視窗所在的顯示器;否則會參照應用程式主視窗所在的顯" +"示器。" #: ../../library/tkinter.rst:2076 msgid "Return true if the widget is currently mapped, false otherwise." -msgstr "" +msgstr "如果元件目前已被映射(mapped)則回傳 true,否則回傳 false。" #: ../../library/tkinter.rst:2080 msgid "" "Return the name of the geometry manager currently responsible for the " "widget, or an empty string if it is not managed by any geometry manager." msgstr "" +"回傳目前負責該元件的佈局管理器名稱,如果沒有任何佈局管理器管理該元件則回傳空" +"字串。" #: ../../library/tkinter.rst:2085 msgid "" "Return the widget's name within its parent, as opposed to its full path name." -msgstr "" +msgstr "回傳元件在其父元件中的名稱,而非其完整路徑名稱。" #: ../../library/tkinter.rst:2090 msgid "" "Return the path name of the widget's parent, or an empty string if the " "widget is the main window of the application." -msgstr "" +msgstr "回傳元件之父元件的路徑名稱,如果該元件是應用程式的主視窗則回傳空字串。" #: ../../library/tkinter.rst:2095 msgid "" @@ -3256,6 +3663,8 @@ msgid "" "is given, the identifier is looked up on the display of that window; " "otherwise it is looked up on the display of the application's main window." msgstr "" +"回傳識別碼為 *id* 的視窗的路徑名稱。如果有給定 *displayof*,則會在該視窗所在" +"的顯示器上查找該識別碼;否則會在應用程式主視窗所在的顯示器上查找。" #: ../../library/tkinter.rst:2102 msgid "" @@ -3264,6 +3673,9 @@ msgid "" "rounded to the nearest integer; for a fractional result use :meth:" "`winfo_fpixels`." msgstr "" +"回傳元件中對應於螢幕距離 *number*\\ (例如 ``\"2.0c\"`` 或 ``\"1i\"``)的像素" +"數。結果會四捨五入為最接近的整數;若要取得含小數的結果,請使用 :meth:" +"`winfo_fpixels`。" #: ../../library/tkinter.rst:2109 msgid "" @@ -3271,6 +3683,8 @@ msgid "" "root window (or virtual root, if one is in use). Return ``-1`` if the " "pointer is not on the same screen as the widget." msgstr "" +"回傳指標的 *x* 座標(以像素為單位),相對於螢幕的根視窗(若有使用虛擬根視窗則" +"相對於虛擬根視窗)。如果指標不在與元件相同的螢幕上,則回傳 ``-1``。" #: ../../library/tkinter.rst:2115 msgid "" @@ -3279,6 +3693,9 @@ msgid "" "coordinates are ``-1`` if the pointer is not on the same screen as the " "widget." msgstr "" +"回傳指標的座標,為一個 ``(x, y)`` 元組(以像素為單位),相對於螢幕的根視窗" +"(若有使用虛擬根視窗則相對於虛擬根視窗)。如果指標不在與元件相同的螢幕上,則" +"兩個座標皆為 ``-1``。" #: ../../library/tkinter.rst:2122 msgid "" @@ -3286,18 +3703,24 @@ msgid "" "root window (or virtual root, if one is in use). Return ``-1`` if the " "pointer is not on the same screen as the widget." msgstr "" +"回傳指標的 *y* 座標(以像素為單位),相對於螢幕的根視窗(若有使用虛擬根視窗則" +"相對於虛擬根視窗)。如果指標不在與元件相同的螢幕上,則回傳 ``-1``。" #: ../../library/tkinter.rst:2128 msgid "" "Return the widget's requested height in pixels. This is the value used by " "the widget's geometry manager to compute its geometry." msgstr "" +"回傳元件請求的高度(以像素為單位)。這是元件的佈局管理器用來計算其 geometry " +"的值。" #: ../../library/tkinter.rst:2134 msgid "" "Return the widget's requested width in pixels. This is the value used by the " "widget's geometry manager to compute its geometry." msgstr "" +"回傳元件請求的寬度(以像素為單位)。這是元件的佈局管理器用來計算其 geometry " +"的值。" #: ../../library/tkinter.rst:2140 msgid "" @@ -3305,6 +3728,8 @@ msgid "" "the range 0 to 65535, that correspond to *color* in the widget. *color* may " "be specified in any of the forms acceptable for a color option." msgstr "" +"回傳一個 ``(r, g, b)`` 元組,內容為與元件中 *color* 對應的紅、綠、藍強度值," +"範圍為 0 到 65535。*color* 可以用任何色彩選項可接受的形式指定。" #: ../../library/tkinter.rst:2147 msgid "" @@ -3312,6 +3737,7 @@ msgid "" "left corner of the widget's border (or of the widget itself if it has no " "border)." msgstr "" +"回傳元件邊框左上角(若無邊框則為元件本身左上角)在螢幕根視窗中的 *x* 座標。" #: ../../library/tkinter.rst:2153 msgid "" @@ -3319,35 +3745,36 @@ msgid "" "left corner of the widget's border (or of the widget itself if it has no " "border)." msgstr "" +"回傳元件邊框左上角(若無邊框則為元件本身左上角)在螢幕根視窗中的 *y* 座標。" #: ../../library/tkinter.rst:2159 msgid "" "Return the name of the screen associated with the widget, in the form " "``displayName.screenIndex``." -msgstr "" +msgstr "回傳與元件關聯之螢幕的名稱,格式為 ``displayName.screenIndex``。" #: ../../library/tkinter.rst:2164 msgid "" "Return the number of cells in the default colormap for the widget's screen." -msgstr "" +msgstr "回傳元件所在螢幕之預設色彩對映表中的單元數量。" #: ../../library/tkinter.rst:2169 msgid "" "Return the depth of the root window of the widget's screen, that is, the " "number of bits per pixel." -msgstr "" +msgstr "回傳元件所在螢幕的根視窗深度,也就是每個像素的位元數。" #: ../../library/tkinter.rst:2174 msgid "Return the height of the widget's screen in pixels." -msgstr "" +msgstr "回傳元件所在螢幕的高度(以像素為單位)。" #: ../../library/tkinter.rst:2178 msgid "Return the height of the widget's screen in millimeters." -msgstr "" +msgstr "回傳元件所在螢幕的高度(以毫米為單位)。" #: ../../library/tkinter.rst:2182 msgid "Return the width of the widget's screen in millimeters." -msgstr "" +msgstr "回傳元件所在螢幕的寬度(以毫米為單位)。" #: ../../library/tkinter.rst:2186 msgid "" @@ -3355,28 +3782,37 @@ msgid "" "``\"directcolor\"``, ``\"grayscale\"``, ``\"pseudocolor\"``, " "``\"staticcolor\"``, ``\"staticgray\"``, or ``\"truecolor\"``." msgstr "" +"回傳元件所在螢幕的預設視覺類別,為 ``\"directcolor\"``、``\"grayscale\"``、" +"``\"pseudocolor\"``、``\"staticcolor\"``、``\"staticgray\"`` 或 " +"``\"truecolor\"`` 之一。" #: ../../library/tkinter.rst:2192 msgid "Return the width of the widget's screen in pixels." -msgstr "" +msgstr "回傳元件所在螢幕的寬度(以像素為單位)。" #: ../../library/tkinter.rst:2196 msgid "" "Return a string containing information about the server for the widget's " "display. The exact format of this string may vary from platform to platform." msgstr "" +"回傳一個字串,內容為元件所在顯示器之伺服器的相關資訊。此字串的確切格式可能因" +"平台而異。" #: ../../library/tkinter.rst:2202 msgid "" "Return the top-of-hierarchy window containing the widget. In standard Tk " "this is always a :class:`Toplevel` widget." msgstr "" +"回傳包含該元件的最上層階層視窗。在標準 Tk 中,這永遠是一個 :class:`Toplevel` " +"元件。" #: ../../library/tkinter.rst:2207 msgid "" "Return true if the widget and all of its ancestors up through the nearest " "toplevel window are mapped, false otherwise." msgstr "" +"如果元件及其一直到最接近的頂層視窗為止的所有祖先都已被映射,則回傳 ``1``,否" +"則回傳 ``0``。" #: ../../library/tkinter.rst:2212 msgid "" @@ -3384,10 +3820,13 @@ msgid "" "``\"grayscale\"``, ``\"pseudocolor\"``, ``\"staticcolor\"``, " "``\"staticgray\"``, or ``\"truecolor\"``." msgstr "" +"回傳元件的視覺類別,為 ``\"directcolor\"``、``\"grayscale\"``、" +"``\"pseudocolor\"``、``\"staticcolor\"``、``\"staticgray\"`` 或 " +"``\"truecolor\"`` 之一。" #: ../../library/tkinter.rst:2218 msgid "Return the X identifier for the visual for the widget." -msgstr "" +msgstr "回傳元件之視覺的 X 識別碼。" #: ../../library/tkinter.rst:2222 msgid "" @@ -3396,18 +3835,25 @@ msgid "" "integer depth. If *includeids* is true, the X identifier for the visual is " "also included." msgstr "" +"回傳一個列表,描述元件所在螢幕可用的視覺。每個項目由一個視覺類別(見 :meth:" +"`winfo_visual`)加上一個整數深度組成。如果 *includeids* 為 true,則也會包含該" +"視覺的 X 識別碼。" #: ../../library/tkinter.rst:2230 msgid "" "Return the height of the virtual root window associated with the widget if " "there is one; otherwise return the height of the widget's screen." msgstr "" +"如果元件有關聯的虛擬根視窗,則回傳該虛擬根視窗的高度;否則回傳元件所在螢幕的" +"高度。" #: ../../library/tkinter.rst:2235 msgid "" "Return the width of the virtual root window associated with the widget if " "there is one; otherwise return the width of the widget's screen." msgstr "" +"如果元件有關聯的虛擬根視窗,則回傳該虛擬根視窗的寬度;否則回傳元件所在螢幕的" +"寬度。" #: ../../library/tkinter.rst:2240 msgid "" @@ -3415,6 +3861,8 @@ msgid "" "relative to the root window of its screen. This is normally zero or " "negative, and is ``0`` if there is no virtual root window." msgstr "" +"回傳元件關聯之虛擬根視窗相對於其所在螢幕根視窗的 *x* 偏移量。此值通常為零或負" +"數,如果沒有虛擬根視窗則為 ``0``。" #: ../../library/tkinter.rst:2247 msgid "" @@ -3422,6 +3870,8 @@ msgid "" "relative to the root window of its screen. This is normally zero or " "negative, and is ``0`` if there is no virtual root window." msgstr "" +"回傳元件關聯之虛擬根視窗相對於其所在螢幕根視窗的 *y* 偏移量。此值通常為零或負" +"數,如果沒有虛擬根視窗則為 ``0``。" #: ../../library/tkinter.rst:2254 msgid "" @@ -3429,18 +3879,22 @@ msgid "" "width is 1 pixel; it is eventually changed by a geometry manager. See also :" "meth:`winfo_reqwidth`." msgstr "" +"回傳元件的寬度(以像素為單位)。視窗剛建立時寬度為 1 像素,之後會由佈局管理器" +"變更。另請參閱 :meth:`winfo_reqwidth`。" #: ../../library/tkinter.rst:2261 msgid "" "Return the *x* coordinate, in the widget's parent, of the upper-left corner " "of the widget's border (or of the widget itself if it has no border)." msgstr "" +"回傳元件邊框左上角(若無邊框則為元件本身左上角)在其父元件中的 *x* 座標。" #: ../../library/tkinter.rst:2267 msgid "" "Return the *y* coordinate, in the widget's parent, of the upper-left corner " "of the widget's border (or of the widget itself if it has no border)." msgstr "" +"回傳元件邊框左上角(若無邊框則為元件本身左上角)在其父元件中的 *y* 座標。" #: ../../library/tkinter.rst:2273 msgid "" @@ -3450,6 +3904,11 @@ msgid "" "Converting it to a string gives the version in the usual Tcl/Tk notation, " "for example ``'9.0.3'`` for a final release or ``'9.1b2'`` for a pre-release." msgstr "" +"以附名元組回傳 Tcl/Tk 的修補等級,其欄位與 :data:`sys.version_info` 相同的五" +"個欄位:*major*、*minor*、*micro*、*releaselevel* 和 *serial*。" +"*releaselevel* 為 ``'alpha'``、``'beta'`` 或 ``'final'``。將其轉換為字串會得" +"到常見 Tcl/Tk 表示法的版本,例如正式版為 ``'9.0.3'``,預先發布版則為 " +"``'9.1b2'``。" #: ../../library/tkinter.rst:2287 msgid "" @@ -3462,6 +3921,11 @@ msgid "" "example, :meth:`title` and :meth:`wm_title`). See also :ref:`tkinter-window-" "manager`." msgstr "" +":class:`!Wm` mixin 提供了對視窗管理器的存取,讓應用程式得以控制頂層視窗的標" +"題、geometry 和圖示等項目,以及它被調整大小的方式,還有它如何回應視窗管理器通" +"訊協定。它被混入 :class:`Tk` 和 :class:`Toplevel` 中,因此其方法在每個頂層視" +"窗上皆可使用。每個方法都有兩種相同效果的寫法:一個簡短名稱和一個 ``wm_`` 前綴" +"的名稱(例如 :meth:`title` 和 :meth:`wm_title`)。" #: ../../library/tkinter.rst:2302 msgid "" @@ -3472,6 +3936,10 @@ msgid "" "four current values, or ``None`` if no aspect restriction is in effect. :" "meth:`wm_aspect` is an alias of :meth:`!aspect`." msgstr "" +"限制視窗的長寬比(寬度與高度的比例)。如果四個引數都有給定,視窗管理器會將比" +"例保持在 ``minNumer/minDenom`` 和 ``maxNumer/maxDenom`` 之間;傳入空字串會移" +"除任何現有的限制。不傳入引數時,回傳目前四個值組成的元組,如果沒有生效中的長" +"寬比限制則回傳空字串。:meth:`wm_aspect` 是 :meth:`!aspect` 的別名。" #: ../../library/tkinter.rst:2315 msgid "" @@ -3481,30 +3949,38 @@ msgid "" "name such as ``'alpha'`` returns the value of that option, and options are " "set using keyword arguments (``alpha=0.5``)." msgstr "" +"查詢或設定視窗的平台特定屬性。不傳入引數時,回傳平台特定的旗標及其值;將 " +"*return_python_dict* 傳入 true 可以將其取得為 dictionary。傳入單一選項名稱" +"(例如 ``'alpha'``)會回傳該選項的值,而選項則是使用關鍵字引數設定的" +"(``alpha=0.5``)。" #: ../../library/tkinter.rst:2321 msgid "The available attributes differ by platform. All platforms support:" -msgstr "" +msgstr "各平台支援的屬性有所不同。所有平台皆支援:" #: ../../library/tkinter.rst:2324 msgid "*alpha*" -msgstr "" +msgstr "*alpha*" #: ../../library/tkinter.rst:2325 msgid "" "The window's opacity, from ``0.0`` (fully transparent) to ``1.0`` (opaque). " "Where transparency is unsupported the value stays at ``1.0``." msgstr "" +"視窗的不透明度,範圍從 ``0.0``\\ (完全透明)到 ``1.0``\\ (不透明)。在不支" +"援透明度的地方,此值會保持在 ``1.0``。" #: ../../library/tkinter.rst:2329 msgid "*appearance*" -msgstr "" +msgstr "*appearance*" #: ../../library/tkinter.rst:2330 msgid "" "Whether the window is rendered in dark mode on Windows and macOS: " "``'auto'``, ``'light'`` or ``'dark'`` (this has no effect on X11)." msgstr "" +"視窗是否以深色模式在 Windows 和 macOS 上呈現:``'auto'``、``'light'`` 或 " +"``'dark'``\\ (這在 X11 上沒有作用)。" #: ../../library/tkinter.rst:2333 msgid "*fullscreen*" @@ -3512,47 +3988,47 @@ msgstr "*fullscreen*" #: ../../library/tkinter.rst:2334 msgid "Whether the window takes up the entire screen and has no borders." -msgstr "" +msgstr "視窗是否佔滿整個螢幕且沒有邊框。" #: ../../library/tkinter.rst:2336 msgid "*topmost*" -msgstr "" +msgstr "*topmost*" #: ../../library/tkinter.rst:2337 msgid "Whether the window is displayed above all other windows." -msgstr "" +msgstr "視窗是否顯示於所有其他視窗之上。" #: ../../library/tkinter.rst:2339 msgid "Windows additionally supports:" -msgstr "" +msgstr "Windows 額外支援:" #: ../../library/tkinter.rst:2341 msgid "*disabled*" -msgstr "" +msgstr "*disabled*" #: ../../library/tkinter.rst:2342 msgid "Whether the window is in a disabled state." -msgstr "" +msgstr "視窗是否處於停用狀態。" #: ../../library/tkinter.rst:2344 msgid "*toolwindow*" -msgstr "" +msgstr "*toolwindow*" #: ../../library/tkinter.rst:2345 msgid "Whether the window uses the tool window style." -msgstr "" +msgstr "視窗是否使用工具視窗樣式。" #: ../../library/tkinter.rst:2347 msgid "*transparentcolor*" -msgstr "" +msgstr "*transparentcolor*" #: ../../library/tkinter.rst:2348 msgid "The color that is made fully transparent, or an empty string for none." -msgstr "" +msgstr "被設為完全透明的顏色,如果沒有則為空字串。" #: ../../library/tkinter.rst:2350 msgid "macOS additionally supports:" -msgstr "" +msgstr "macOS 額外支援:" #: ../../library/tkinter.rst:2352 msgid "*class*" @@ -3563,72 +4039,77 @@ msgid "" "Whether the underlying Aqua window is an ``nswindow`` or an ``nspanel``; " "this can only be set before the window is created." msgstr "" +"底層的 Aqua 視窗是 ``nswindow`` 還是 ``nspanel``;此項只能在視窗建立之前設" +"定。" #: ../../library/tkinter.rst:2356 msgid "*modified*" -msgstr "" +msgstr "*modified*" #: ../../library/tkinter.rst:2357 msgid "" "The modification state shown by the window's close button and proxy icon." -msgstr "" +msgstr "由視窗的關閉按鈕和代理圖示顯示的修改狀態。" #: ../../library/tkinter.rst:2360 msgid "*notify*" -msgstr "" +msgstr "*notify*" #: ../../library/tkinter.rst:2361 msgid "Whether the application's dock icon bounces to request attention." -msgstr "" +msgstr "應用程式的 Dock 圖示是否會跳動以要求關注。" #: ../../library/tkinter.rst:2363 msgid "*stylemask*" -msgstr "" +msgstr "*stylemask*" #: ../../library/tkinter.rst:2364 msgid "" "The style mask of the underlying Aqua window, given as a list of bit names " "such as ``titled`` or ``resizable``." msgstr "" +"底層 Aqua 視窗的樣式遮罩,以位元名稱列表的形式給出,例如 ``titled`` 或 " +"``resizable``。" #: ../../library/tkinter.rst:2367 msgid "*tabbingid*" -msgstr "" +msgstr "*tabbingid*" #: ../../library/tkinter.rst:2368 msgid "The identifier of the tab group that the window belongs to." -msgstr "" +msgstr "視窗所屬分頁群組的識別碼。" #: ../../library/tkinter.rst:2370 msgid "*tabbingmode*" -msgstr "" +msgstr "*tabbingmode*" #: ../../library/tkinter.rst:2371 msgid "" "Whether the window may be opened as a tab: ``'auto'``, ``'preferred'`` or " "``'disallowed'``." msgstr "" +"視窗是否可以作為分頁開啟:``'auto'``、``'preferred'`` 或 ``'disallowed'``。" #: ../../library/tkinter.rst:2374 msgid "*titlepath*" -msgstr "" +msgstr "*titlepath*" #: ../../library/tkinter.rst:2375 msgid "The path of the file represented by the window's proxy icon." -msgstr "" +msgstr "視窗代理圖示所代表之檔案的路徑。" #: ../../library/tkinter.rst:2377 msgid "*transparent*" -msgstr "" +msgstr "*transparent*" #: ../../library/tkinter.rst:2378 msgid "" "Whether the content area is transparent and the window shadow is turned off." -msgstr "" +msgstr "內容區域是否透明,以及視窗陰影是否關閉。" #: ../../library/tkinter.rst:2381 msgid "X11 additionally supports:" -msgstr "" +msgstr "X11 額外支援:" #: ../../library/tkinter.rst:2383 msgid "*type*" @@ -3640,20 +4121,24 @@ msgid "" "manager should use to interpret the window, such as ``'dialog'`` or " "``'splash'``." msgstr "" +"視窗管理器應用來解讀該視窗的視窗類型,或依偏好順序排列的類型列表,例如 " +"``'dialog'`` 或 ``'splash'``。" #: ../../library/tkinter.rst:2388 msgid "*zoomed*" -msgstr "" +msgstr "*zoomed*" #: ../../library/tkinter.rst:2389 msgid "Whether the window is maximized." -msgstr "" +msgstr "視窗是否已最大化。" #: ../../library/tkinter.rst:2393 msgid "" "Tk 8.6 added the *type* attribute, and Tk 9.0 added the *appearance*, " "*class*, *stylemask*, *tabbingid* and *tabbingmode* attributes." msgstr "" +"Tk 8.6 新增了 *type* 屬性,Tk 9.0 新增了 *appearance*、*class*、*stylemask*、" +"*tabbingid* 和 *tabbingmode* 屬性。" #: ../../library/tkinter.rst:2396 msgid "" @@ -3661,6 +4146,8 @@ msgid "" "reflect the most recent request. :meth:`wm_attributes` is an alias of :meth:" "`!attributes`." msgstr "" +"在 X11 上,變更是非同步套用的,因此查詢到的值可能尚未反映最近的請求。:meth:" +"`wm_attributes` 是 :meth:`!attributes` 的別名。" #: ../../library/tkinter.rst:2400 msgid "" @@ -3668,6 +4155,8 @@ msgid "" "attributes may be set using keyword arguments. The *return_python_dict* " "parameter was added." msgstr "" +"現在可以透過不含開頭 ``-`` 的名稱來查詢單一屬性,且屬性可以使用關鍵字引數設" +"定。新增了 *return_python_dict* 參數。" #: ../../library/tkinter.rst:2405 msgid "" @@ -3675,6 +4164,8 @@ msgid "" "its value as two positional arguments, as in ``w.attributes('-alpha', " "0.5)``, is deprecated; use keyword arguments instead." msgstr "" +"透過傳入選項名稱(帶有開頭的 ``-``)及其值作為兩個位置引數來設定屬性,如 ``w." +"attributes('-alpha', 0.5)`` 這樣的用法已被棄用;請改用關鍵字引數。" #: ../../library/tkinter.rst:2417 msgid "" @@ -3684,6 +4175,10 @@ msgid "" "argument, return the last name set, or an empty string. :meth:`wm_client` is " "an alias of :meth:`!client`." msgstr "" +"將 *name* (應為執行該應用程式之主機的名稱)儲存到視窗的 " +"``WM_CLIENT_MACHINE`` 屬性中,供視窗或工作階段管理器使用。空字串會刪除該屬" +"性。不傳入引數時,回傳最後設定的名稱,或空字串。:meth:`wm_client` 是 :meth:`!" +"client` 的別名。" #: ../../library/tkinter.rst:2429 msgid "" @@ -3694,6 +4189,10 @@ msgid "" "currently named in the property. :meth:`wm_colormapwindows` is an alias of :" "meth:`!colormapwindows`." msgstr "" +"操作 ``WM_COLORMAP_WINDOWS`` 屬性,此屬性會告知視窗管理器哪些視窗擁有私有色彩" +"對映表。如果有給定 *wlist*,則會用這些視窗覆寫該屬性(其順序為安裝色彩對映表" +"的優先順序)。不傳入引數時,回傳目前在該屬性中列出的視窗列表。:meth:" +"`wm_colormapwindows` 是 :meth:`!colormapwindows` 的別名。" #: ../../library/tkinter.rst:2442 msgid "" @@ -3703,6 +4202,10 @@ msgid "" "argument, return the last value set, or an empty string. :meth:`wm_command` " "is an alias of :meth:`!command`." msgstr "" +"將 *value* 儲存到視窗的 ``WM_COMMAND`` 屬性中,供視窗或工作階段管理器使用;它" +"應該是一個列表,內容為用來呼叫該應用程式之指令的各個字詞。空字串會刪除該屬" +"性。不傳入引數時,回傳最後設定的值,或空字串。:meth:`wm_command` 是 :meth:`!" +"command` 的別名。" #: ../../library/tkinter.rst:2454 msgid "" @@ -3711,6 +4214,10 @@ msgid "" "is first mapped. On Windows the window is also raised and given the focus. :" "meth:`wm_deiconify` is an alias of :meth:`!deiconify`." msgstr "" +"以映射的方式,將視窗以正常(未圖示化)的形式顯示出來。如果該視窗從未被映射" +"過,這會確保它在第一次被映射時就以取消圖示化的狀態出現。在 Windows 上,該視窗" +"也會被提升到最上層並取得焦點。:meth:`wm_deiconify` 是 :meth:`!deiconify` 的別" +"名。" #: ../../library/tkinter.rst:2465 msgid "" @@ -3722,6 +4229,11 @@ msgid "" "focus` command assumes. :meth:`wm_focusmodel` is an alias of :meth:`!" "focusmodel`." msgstr "" +"設定或查詢視窗的焦點模型。*model* 是 ``'active'``\\ (視窗會為自己或其子代宣" +"告輸入焦點,即使焦點目前在其他應用程式中)或 ``'passive'``\\ (視窗依賴視窗管" +"理器將焦點給予它)兩者之一。不傳入引數時,回傳目前的模型。預設值為 " +"``'passive'``,這也是 :meth:`!focus` 指令所假定的模型。:meth:`wm_focusmodel` " +"是 :meth:`!focusmodel` 的別名。" #: ../../library/tkinter.rst:2480 msgid "" @@ -3730,10 +4242,14 @@ msgid "" "its ``-menu`` configuration is remembered and the menu reappears if the " "widget is managed again. :meth:`wm_forget` is an alias of :meth:`!forget`." msgstr "" +"將 *window* 從螢幕上取消映射,使其不再由視窗管理器管理。此後 :class:" +"`Toplevel` 會被當作 :class:`Frame` 對待,不過其 ``-menu`` 設定仍會被記住,且" +"該元件再次被管理時選單會重新出現。:meth:`wm_forget` 是 :meth:`!forget` 的別" +"名。" #: ../../library/tkinter.rst:2487 msgid "Not to be confused with :meth:`Pack.forget`." -msgstr "" +msgstr "請勿與 :meth:`Pack.forget` 混淆。" #: ../../library/tkinter.rst:2496 msgid "" @@ -3742,6 +4258,9 @@ msgid "" "such a frame; otherwise return the identifier of the window itself. :meth:" "`wm_frame` is an alias of :meth:`!frame`." msgstr "" +"回傳包含該視窗之最外層裝飾框架的平台特定視窗識別碼,前提是視窗管理器已將其重" +"新設定父視窗至該框架中;否則回傳該視窗本身的識別碼。:meth:`wm_frame` 是 :" +"meth:`!frame` 的別名。" #: ../../library/tkinter.rst:2507 msgid "" @@ -3757,6 +4276,13 @@ msgid "" "the form ``'200x200+10+10'``. :meth:`wm_geometry` is an alias of :meth:`!" "geometry`." msgstr "" +"設定或查詢視窗的 geometry。*newGeometry* 的格式為 ``=widthxheight+x+y``,其" +"中 ``=``、``widthxheight`` 和 ``+x+y`` 位置皆可省略。*width* 和 *height* 的單" +"位為像素(若視窗為網格化視窗則為網格單位);以 ``+`` 開頭的位置是從螢幕左邊或" +"上邊測量,以 ``-`` 開頭的位置則是從螢幕右邊或下邊測量。空字串會取消任何使用者" +"指定的 geometry,讓視窗回復到自然大小。不傳入引數時,回傳目前的 geometry,格" +"式如 ``'200x200+10+10'`` 的字串。:meth:`wm_geometry` 是 :meth:`!geometry` 的" +"別名。" #: ../../library/tkinter.rst:2526 msgid "" @@ -3768,10 +4294,15 @@ msgid "" "of the four current values, or ``None`` if the window is not gridded. :meth:" "`wm_grid` is an alias of :meth:`!grid`." msgstr "" +"將視窗管理為網格化視窗,並定義網格單位與像素之間的關係。*baseWidth* 和 " +"*baseHeight* 是視窗內部請求大小所對應的網格單位數,*widthInc* 和 *heightInc* " +"則是水平和垂直網格單位的像素大小。傳入空字串會關閉網格化管理。不傳入引數時," +"回傳目前四個值組成的元組,如果視窗未網格化則回傳空字串。:meth:`wm_grid` 是 :" +"meth:`!grid` 的別名。" #: ../../library/tkinter.rst:2536 msgid "Not to be confused with the grid geometry manager :meth:`Grid.grid`." -msgstr "" +msgstr "請勿與網格佈局管理器 :meth:`Grid.grid` 混淆。" #: ../../library/tkinter.rst:2543 msgid "" @@ -3782,6 +4313,10 @@ msgid "" "the current group leader, or an empty string. :meth:`wm_group` is an alias " "of :meth:`!group`." msgstr "" +"設定或查詢一組相關視窗的領導者。*pathName* 給定群組領導者的路徑名稱;例如,當" +"領導者被圖示化時,視窗管理器可能會將群組中的所有視窗取消映射。空字串會將該視" +"窗從任何群組中移除。不傳入引數時,回傳目前群組領導者的路徑名稱,或空字串。:" +"meth:`wm_group` 是 :meth:`!group` 的別名。" #: ../../library/tkinter.rst:2557 msgid "" @@ -3793,6 +4328,11 @@ msgid "" "all top-level windows that have no icon of their own. :meth:`wm_iconbitmap` " "is an alias of :meth:`!iconbitmap`." msgstr "" +"設定或查詢視窗管理器用於該視窗圖示的點陣圖。*bitmap* 以 Tk 接受的標準形式之一" +"指定一個點陣圖;空字串會取消目前的圖示點陣圖。不傳入引數時,回傳目前圖示點陣" +"圖的名稱,或空字串。在 Windows 上,*default* 引數指定一個圖示(例如一個 ``." +"ico`` 檔案),套用到所有沒有自己圖示的頂層視窗。:meth:`wm_iconbitmap` 是 :" +"meth:`!iconbitmap` 的別名。" #: ../../library/tkinter.rst:2571 msgid "" @@ -3800,6 +4340,8 @@ msgid "" "time, arrange for it to appear in the iconified state when it is eventually " "mapped. :meth:`wm_iconify` is an alias of :meth:`!iconify`." msgstr "" +"將視窗圖示化。如果該視窗尚未第一次被映射過,則安排它在最終被映射時以圖示化狀" +"態出現。:meth:`wm_iconify` 是 :meth:`!iconify` 的別名。" #: ../../library/tkinter.rst:2581 msgid "" @@ -3810,6 +4352,10 @@ msgid "" "mask, or an empty string. :meth:`wm_iconmask` is an alias of :meth:`!" "iconmask`." msgstr "" +"設定或查詢用作圖示遮罩的點陣圖(見 :meth:`iconbitmap`)。遮罩中為零的地方不會" +"顯示圖示;為一的地方,則會顯示圖示點陣圖對應的位元。空字串會取消目前的遮罩。" +"不傳入引數時,回傳目前圖示遮罩的名稱,或空字串。:meth:`wm_iconmask` 是 :meth:" +"`!iconmask` 的別名。" #: ../../library/tkinter.rst:2595 msgid "" @@ -3818,6 +4364,9 @@ msgid "" "none has been set (in which case the window manager normally displays the " "window's title). :meth:`wm_iconname` is an alias of :meth:`!iconname`." msgstr "" +"設定或查詢視窗管理器在視窗圖示內顯示的名稱。不傳入引數時,回傳目前的圖示名" +"稱,如果尚未設定則回傳空字串(此時視窗管理器通常會顯示視窗的標題)。:meth:" +"`wm_iconname` 是 :meth:`!iconname` 的別名。" #: ../../library/tkinter.rst:2607 msgid "" @@ -3830,6 +4379,11 @@ msgid "" "macOS only the first image is used. :meth:`wm_iconphoto` is an alias of :" "meth:`!iconphoto`." msgstr "" +"從 *images* 中給定的一個或多個 :class:`PhotoImage` 物件設定視窗的標題列圖示。" +"可以提供多張不同大小的圖片(例如 16x16 和 32x32),讓視窗管理器可以選擇合適的" +"一張。圖片資料是在呼叫當下擷取的快照;之後對圖片的變更不會反映出來。如果 " +"*default* 為 true,該圖示也會套用到未來建立的所有頂層視窗。在 macOS 上只會使" +"用第一張圖片。:meth:`wm_iconphoto` 是 :meth:`!iconphoto` 的別名。" #: ../../library/tkinter.rst:2625 msgid "" @@ -3838,6 +4392,9 @@ msgid "" "arguments, return a tuple of the two current values, or ``None`` if no hint " "is in effect. :meth:`wm_iconposition` is an alias of :meth:`!iconposition`." msgstr "" +"設定或查詢提示視窗管理器該視窗圖示應放置於何處的提示值。空字串會取消現有的提" +"示值。不傳入引數時,回傳目前兩個值組成的元組,如果沒有生效中的提示值則回傳空" +"字串。:meth:`wm_iconposition` 是 :meth:`!iconposition` 的別名。" #: ../../library/tkinter.rst:2637 msgid "" @@ -3849,6 +4406,11 @@ msgid "" "meaningless on non-X11 platforms. :meth:`wm_iconwindow` is an alias of :meth:" "`!iconwindow`." msgstr "" +"設定或查詢用作該視窗圖示的視窗。當該視窗被圖示化時,*pathName* 會被映射以作為" +"其圖示,並在其取消圖示化時再次取消映射。空字串會取消此關聯。不傳入引數時,回" +"傳目前圖示視窗的路徑名稱,或空字串。並非所有視窗管理器都支援圖示視窗,且此概" +"念在非 X11 平台上沒有意義。:meth:`wm_iconwindow` 是 :meth:`!iconwindow` 的別" +"名。" #: ../../library/tkinter.rst:2652 msgid "" @@ -3858,6 +4420,10 @@ msgid "" "are **not** accepted); passing any other widget type raises an error. :meth:" "`wm_manage` is an alias of :meth:`!manage`." msgstr "" +"使 *widget* 成為一個獨立的頂層視窗,並由視窗管理器加上標題列等裝飾。只能使" +"用 :class:`Frame`、:class:`LabelFrame` 和 :class:`Toplevel` 元件(**不**\\ 接" +"受 :mod:`tkinter.ttk` 版本);傳入任何其他元件類型都會引發錯誤。:meth:" +"`wm_manage` 是 :meth:`!manage` 的別名。" #: ../../library/tkinter.rst:2666 msgid "" @@ -3867,6 +4433,10 @@ msgid "" "the current maximum width and height. The maximum size defaults to the size " "of the screen. :meth:`wm_maxsize` is an alias of :meth:`!maxsize`." msgstr "" +"設定或查詢視窗的最大允許尺寸,以像素為單位(若視窗為網格化視窗則為網格單" +"位)。視窗管理器會限制視窗不得大於 *width* 和 *height*。不傳入引數時,回傳目" +"前最大寬度和高度組成的元組。最大尺寸預設為螢幕的大小。:meth:`wm_maxsize` 是 :" +"meth:`!maxsize` 的別名。" #: ../../library/tkinter.rst:2680 msgid "" @@ -3876,6 +4446,10 @@ msgid "" "of the current minimum width and height. The minimum size defaults to one " "pixel in each dimension. :meth:`wm_minsize` is an alias of :meth:`!minsize`." msgstr "" +"設定或查詢視窗的最小允許尺寸,以像素為單位(若視窗為網格化視窗則為網格單" +"位)。視窗管理器會限制視窗不得小於 *width* 和 *height*。不傳入引數時,回傳目" +"前最小寬度和高度組成的元組。最小尺寸預設為每個維度 1 像素。:meth:" +"`wm_minsize` 是 :meth:`!minsize` 的別名。" #: ../../library/tkinter.rst:2694 msgid "" @@ -3888,6 +4462,11 @@ msgid "" "withdrawn state. :meth:`wm_overrideredirect` is an alias of :meth:`!" "overrideredirect`." msgstr "" +"設定或查詢視窗的 override-redirect 旗標。設定此旗標時,視窗管理器會忽略該視" +"窗:它不會被重新設定父視窗到裝飾框架中,使用者也無法透過一般的視窗管理器控制" +"項來操作它。不傳入引數時,回傳一個布林值,表示該旗標是否已設定。此旗標只有在" +"視窗第一次被映射或從撤回狀態重新映射時才會可靠地被遵循。:meth:" +"`wm_overrideredirect` 是 :meth:`!overrideredirect` 的別名。" #: ../../library/tkinter.rst:2709 msgid "" @@ -3899,6 +4478,11 @@ msgid "" "`geometry` is called, unless it has been set explicitly to ``'program'``. :" "meth:`wm_positionfrom` is an alias of :meth:`!positionfrom`." msgstr "" +"設定或查詢視窗目前位置的來源。*who* 是 ``'program'`` 或 ``'user'`` 兩者之一," +"表示該位置是由程式還是由使用者所要求的;空字串會取消目前的來源。不傳入引數" +"時,回傳目前的來源,如果尚未設定則回傳空字串。當 :meth:`geometry` 被呼叫時," +"Tk 會自動將來源設為 ``'user'``,除非它已明確設為 ``'program'``。:meth:" +"`wm_positionfrom` 是 :meth:`!positionfrom` 的別名。" #: ../../library/tkinter.rst:2724 msgid "" @@ -3913,6 +4497,14 @@ msgid "" "arguments, return a tuple of the protocols that currently have handlers. :" "meth:`wm_protocol` is an alias of :meth:`!protocol`." msgstr "" +"將 *func* 註冊為視窗管理器通訊協定 *name*\\ (一個 atom,例如 " +"``'WM_DELETE_WINDOW'``、``'WM_SAVE_YOURSELF'`` 或 ``'WM_TAKE_FOCUS'``)的處理" +"常式;每當視窗管理器傳送該通訊協定的訊息時,就會呼叫 *func*。Tk 安裝了一個預" +"設的 ``WM_DELETE_WINDOW`` 處理常式來銷毀該視窗,這個方法可以取代它。如果 " +"*func* 為空字串,則會移除該處理常式。只傳入 *name* 時,回傳其已註冊之處理常式" +"指令的名稱,如果沒有設定則回傳空字串(不會回報預設的 ``WM_DELETE_WINDOW`` 處" +"理常式);不傳入引數時,回傳目前有處理常式的通訊協定組成的元組。:meth:" +"`wm_protocol` 是 :meth:`!protocol` 的別名。" #: ../../library/tkinter.rst:2742 msgid "" @@ -3923,6 +4515,10 @@ msgid "" "a window is resizable in both dimensions. :meth:`wm_resizable` is an alias " "of :meth:`!resizable`." msgstr "" +"控制使用者是否可以互動式地調整視窗大小。*width* 和 *height* 是布林值,決定視" +"窗的寬度和高度是否可以變更。不傳入引數時,回傳一個由兩個 ``0``/``1`` 值組成的" +"元組,表示每個維度目前是否可調整大小。預設情況下,視窗在兩個維度上都可調整大" +"小。:meth:`wm_resizable` 是 :meth:`!resizable` 的別名。" #: ../../library/tkinter.rst:2755 msgid "" @@ -3932,6 +4528,10 @@ msgid "" "no argument, return the current source, or an empty string if none has been " "set. :meth:`wm_sizefrom` is an alias of :meth:`!sizefrom`." msgstr "" +"設定或查詢視窗目前大小的來源。*who* 是 ``'program'`` 或 ``'user'`` 兩者之一," +"表示該大小是由程式還是由使用者所要求的;空字串會取消目前的來源。不傳入引數" +"時,回傳目前的來源,如果尚未設定則回傳空字串。:meth:`wm_sizefrom` 是 :meth:`!" +"sizefrom` 的別名。" #: ../../library/tkinter.rst:2768 msgid "" @@ -3942,11 +4542,16 @@ msgid "" "for another window (see :meth:`iconwindow`); the ``'icon'`` state cannot be " "set. :meth:`wm_state` is an alias of :meth:`!state`." msgstr "" +"設定或查詢視窗的狀態。不傳入引數時,回傳目前的狀態:``'normal'``、" +"``'iconic'``、``'withdrawn'``、``'icon'`` 之一,或者僅限 Windows 和 macOS 的 " +"``'zoomed'``。``'iconic'`` 指的是已被圖示化的視窗,而 ``'icon'`` 指的是作為另" +"一個視窗之圖示的視窗(見 :meth:`iconwindow`);``'icon'`` 狀態無法被設定。:" +"meth:`wm_state` 是 :meth:`!state` 的別名。" #: ../../library/tkinter.rst:2777 msgid "" "Not to be confused with :meth:`ttk.Widget.state `." -msgstr "" +msgstr "請勿與 :meth:`ttk.Widget.state ` 混淆。" #: ../../library/tkinter.rst:2785 msgid "" @@ -3955,6 +4560,9 @@ msgid "" "title. The title defaults to the window's name. :meth:`wm_title` is an alias " "of :meth:`!title`." msgstr "" +"設定或查詢視窗的標題,視窗管理器應在視窗的標題列中顯示此標題。不傳入引數時," +"回傳目前的標題。標題預設為視窗的名稱。:meth:`wm_title` 是 :meth:`!title` 的別" +"名。" #: ../../library/tkinter.rst:2796 msgid "" @@ -3966,6 +4574,11 @@ msgid "" "manager; it is an error to make a window a transient of itself. :meth:" "`wm_transient` is an alias of :meth:`!transient`." msgstr "" +"將視窗標記為一個代表 *master* (另一個頂層視窗的路徑名稱)運作的暫時性視窗" +"(例如下拉選單或對話方塊)。空字串會清除暫時性狀態。不傳入引數時,回傳目前主" +"控視窗的路徑名稱,或空字串。暫時性視窗會鏡射其主控視窗的狀態變化,且視窗管理" +"器可能會以不同方式裝飾它;將視窗設為自己的暫時性視窗會是一個錯誤。:meth:" +"`wm_transient` 是 :meth:`!transient` 的別名。" #: ../../library/tkinter.rst:2812 msgid "" @@ -3976,6 +4589,10 @@ msgid "" "some window managers notice changes to window attributes. :meth:" "`wm_withdraw` is an alias of :meth:`!withdraw`." msgstr "" +"將視窗從螢幕上撤回,取消其映射並使視窗管理器忘記它。如果該視窗從未被映射過," +"則會改為以撤回狀態映射。有時必須撤回視窗然後重新映射它(例如使用 :meth:" +"`deiconify`),才能讓某些視窗管理器注意到視窗屬性的變化。:meth:`wm_withdraw` " +"是 :meth:`!withdraw` 的別名。" #: ../../library/tkinter.rst:2824 msgid "" @@ -3985,6 +4602,9 @@ msgid "" "with the *pack* geometry manager. See also :ref:`tkinter-geometry-" "management`." msgstr "" +"透過將元件緊靠其容器的邊來排列元件的佈局管理器。:class:`!Pack` mix-in 由所有" +"元件所繼承(透過 :class:`Widget`),並提供使用 *pack* 佈局管理器管理元件的方" +"法。另請參閱 :ref:`pack-the-packer`。" #: ../../library/tkinter.rst:2833 msgid "" @@ -3998,12 +4618,22 @@ msgid "" "``pack_*``, ``grid_*`` and ``place_*`` methods (and ``pack``, ``grid``, " "``place`` for geometry configuration) to act on a specific geometry manager." msgstr "" +":class:`Pack`、:class:`Place` 和 :class:`Grid` 都定義了相同的簡短方法名稱 :" +"meth:`!forget`、:meth:`!info`、:meth:`!slaves`、:meth:`!content` 和 :meth:`!" +"propagate`。在元件上,這些簡短名稱會解析為 *pack* 管理器的版本,因為無論實際" +"上是哪個管理器在管理該元件,:class:`Pack` 和 :class:`Misc` 在方法解析順序中都" +"排在 :class:`Place` 和 :class:`Grid` 之前;而 :meth:`!configure`/:meth:`!" +"config` 設定的是元件的選項,而非其 geometry。請使用明確的 ``pack_*``、" +"``grid_*`` 和 ``place_*`` 方法(以及用於 geometry 設定的 ``pack``、``grid``、" +"``place``)來針對特定的佈局管理器進行操作。" #: ../../library/tkinter.rst:2855 msgid "" "Pack the widget inside its container, positioning it relative to the " "siblings already packed there. The supported options are:" msgstr "" +"在元件的容器內排列它,使其相對於已經 pack 在該處的同層元件定位。支援的選項" +"有:" #: ../../library/tkinter.rst:2859 msgid "*side*" @@ -4014,6 +4644,8 @@ msgid "" "Which side of the container to pack the widget against: ``'top'`` (the " "default), ``'bottom'``, ``'left'`` or ``'right'``." msgstr "" +"要將元件緊靠容器的哪一側:``'top'``\\ (預設值)、``'bottom'``、``'left'`` " +"或 ``'right'``。" #: ../../library/tkinter.rst:2863 ../../library/tkinter.rst:3487 msgid "*fill*" @@ -4024,6 +4656,8 @@ msgid "" "Whether to stretch the widget to fill its parcel: ``'none'`` (the default), " "``'x'``, ``'y'`` or ``'both'``." msgstr "" +"是否要拉伸元件以填滿它的位置:``'none'``\\ (預設值)、``'x'``、``'y'`` 或 " +"``'both'``。" #: ../../library/tkinter.rst:2867 msgid "*expand*" @@ -4033,7 +4667,7 @@ msgstr "*expand*" msgid "" "Whether the widget should expand to consume any extra space in its container " "(a boolean, default false)." -msgstr "" +msgstr "元件是否應該擴展以消耗其容器中任何額外的空間(布林值,預設為 false)。" #: ../../library/tkinter.rst:2871 ../../library/tkinter.rst:2977 #: ../../library/tkinter.rst:3597 ../../library/tkinter.rst:3616 @@ -4046,6 +4680,8 @@ msgid "" "Where to position the widget in its parcel when the parcel is larger than " "the widget: an anchor such as ``'n'`` or ``'sw'`` (default ``'center'``)." msgstr "" +"當元件所在的位置比元件本身大時,元件在該位置中要放在哪裡:一個錨點,例如 " +"``'n'`` 或 ``'sw'``\\ (預設為 ``'center'``)。" #: ../../library/tkinter.rst:2876 ../../library/tkinter.rst:3071 msgid "*ipadx*, *ipady*" @@ -4056,6 +4692,8 @@ msgid "" "Internal padding added on the left and right (*ipadx*) or top and bottom " "(*ipady*) of the widget, as a screen distance (default ``0``)." msgstr "" +"在元件的左右(*ipadx*)或上下(*ipady*)新增的內部填充,以螢幕距離表示(預設" +"為 ``0``)。" #: ../../library/tkinter.rst:2880 ../../library/tkinter.rst:3075 msgid "*padx*, *pady*" @@ -4067,42 +4705,46 @@ msgid "" "(*pady*) of the widget, as a screen distance or a pair of two distances for " "the two sides (default ``0``)." msgstr "" +"在元件的左右(*padx*)或上下(*pady*)留出的外部填充,以螢幕距離或兩側各自距" +"離組成的一對值表示(預設為 ``0``)。" #: ../../library/tkinter.rst:2885 msgid "*after*" -msgstr "" +msgstr "*after*" #: ../../library/tkinter.rst:2886 msgid "" "Pack the widget after the given widget in the packing order, using the same " "container." -msgstr "" +msgstr "在排列順序中,將元件排在指定元件之後,並使用相同的容器。" #: ../../library/tkinter.rst:2889 msgid "*before*" -msgstr "" +msgstr "*before*" #: ../../library/tkinter.rst:2890 msgid "" "Pack the widget before the given widget in the packing order, using the same " "container." -msgstr "" +msgstr "在排列順序中,將元件排在指定元件之前,並使用相同的容器。" #: ../../library/tkinter.rst:2893 ../../library/tkinter.rst:2997 #: ../../library/tkinter.rst:3080 msgid "*in_*" -msgstr "" +msgstr "*in_*" #: ../../library/tkinter.rst:2894 msgid "" "The container in which to pack the widget; it defaults to the parent widget." -msgstr "" +msgstr "要將元件排列於其中的容器;預設為父元件。" #: ../../library/tkinter.rst:2897 msgid "" ":meth:`pack`, :meth:`configure` and :meth:`config` are aliases of :meth:`!" "pack_configure`." msgstr "" +":meth:`pack`、:meth:`configure` 和 :meth:`config` 都是 :meth:`!" +"pack_configure` 的別名。" #: ../../library/tkinter.rst:2905 msgid "" @@ -4113,16 +4755,23 @@ msgid "" "PanedWindow `, which provide their own :meth:`!" "forget` method." msgstr "" +"取消映射該元件並將其從排列順序中移除,忘記其排列選項。之後可以再次用 :meth:" +"`pack_configure` 排列它。:meth:`forget` 是 :meth:`!pack_forget` 的別名,但 :" +"class:`PanedWindow`、:class:`ttk.Notebook ` 和 :class:" +"`ttk.PanedWindow ` 除外,它們提供了自己的 :meth:`!" +"forget` 方法。" #: ../../library/tkinter.rst:2914 msgid "Not to be confused with :meth:`Wm.forget`." -msgstr "" +msgstr "請勿與 :meth:`Wm.forget` 混淆。" #: ../../library/tkinter.rst:2921 msgid "" "Return a dictionary of the widget's current packing options. :meth:`info` is " "an alias of :meth:`!pack_info`." msgstr "" +"回傳一個 dictionary,內容為元件目前的排列選項。:meth:`info` 是 :meth:`!" +"pack_info` 的別名。" #: ../../library/tkinter.rst:2931 msgid "" @@ -4130,12 +4779,16 @@ msgid "" "enable or disable geometry propagation. :meth:`propagate` is an alias of :" "meth:`!pack_propagate`." msgstr "" +"與 :meth:`Misc.pack_propagate` 相同,將此元件視為一個容器:啟用或停用 " +"geometry 傳播。:meth:`propagate` 是 :meth:`!pack_propagate` 的別名。" #: ../../library/tkinter.rst:2940 msgid "" "Same as :meth:`Misc.pack_slaves`: return the list of widgets packed in this " "widget. :meth:`slaves` is an alias of :meth:`!pack_slaves`." msgstr "" +"與 :meth:`Misc.pack_slaves` 相同:回傳排列在此元件中的元件列表。:meth:" +"`slaves` 是 :meth:`!pack_slaves` 的別名。" #: ../../library/tkinter.rst:2947 msgid "" @@ -4143,26 +4796,28 @@ msgid "" "their container. The :class:`!Place` mix-in is inherited by all widgets " "(through :class:`Widget`). See also :ref:`tkinter-geometry-management`." msgstr "" +"佈局管理器,在容器內以明確的位置與大小放置元件。:class:`!Place` mix-in 由所有" +"元件(透過 :class:`Widget`)繼承。" #: ../../library/tkinter.rst:2962 msgid "" "Place the widget inside its container at an absolute or relative position. " "The supported options are:" -msgstr "" +msgstr "將元件以絕對或相對位置放置在其容器內。支援的選項如下:" #: ../../library/tkinter.rst:2966 msgid "*x*, *y*" -msgstr "" +msgstr "*x*, *y*" #: ../../library/tkinter.rst:2967 msgid "" "The absolute horizontal and vertical position of the widget's anchor point, " "as a screen distance (default ``0``)." -msgstr "" +msgstr "元件錨點的絕對水平與垂直位置,以螢幕距離表示(預設為 ``0``)。" #: ../../library/tkinter.rst:2970 msgid "*relx*, *rely*" -msgstr "" +msgstr "*relx*, *rely*" #: ../../library/tkinter.rst:2971 msgid "" @@ -4171,26 +4826,30 @@ msgid "" "top edge and ``1.0`` is the right or bottom edge. If both the absolute and " "the relative option are given, their values are summed." msgstr "" +"元件錨點的水平與垂直位置,以容器寬度與高度的分數表示,其中 ``0.0`` 為左邊或上" +"邊,``1.0`` 為右邊或下邊。若同時給定絕對與相對選項,則會將兩者的值相加。" #: ../../library/tkinter.rst:2978 msgid "" "Which point of the widget is placed at the given position: an anchor such as " "``'n'`` or ``'se'`` (default ``'nw'``)." msgstr "" +"元件的哪一點會被放置在給定位置:一個錨點,例如 ``'n'`` 或 ``'se'``\\ (預設" +"為 ``'nw'``)。" #: ../../library/tkinter.rst:2981 ../../library/tkinter.rst:3647 msgid "*width*, *height*" -msgstr "" +msgstr "*width*, *height*" #: ../../library/tkinter.rst:2982 msgid "" "The absolute width and height of the widget, as a screen distance. By " "default the widget's requested size is used." -msgstr "" +msgstr "元件的絕對寬度與高度,以螢幕距離表示。預設會使用元件所要求的大小。" #: ../../library/tkinter.rst:2985 msgid "*relwidth*, *relheight*" -msgstr "" +msgstr "*relwidth*, *relheight*" #: ../../library/tkinter.rst:2986 msgid "" @@ -4198,10 +4857,12 @@ msgid "" "and height. If both the absolute and the relative option are given, their " "values are summed." msgstr "" +"元件的寬度與高度,以容器寬度與高度的分數表示。若同時給定絕對與相對選項,則會" +"將兩者的值相加。" #: ../../library/tkinter.rst:2991 msgid "*bordermode*" -msgstr "" +msgstr "*bordermode*" #: ../../library/tkinter.rst:2992 msgid "" @@ -4209,34 +4870,39 @@ msgid "" "measures the area inside the border, ``'outside'`` measures the area " "including the border, and ``'ignore'`` uses the official X area." msgstr "" +"容器的邊框如何影響放置:``'inside'``\\ (預設)會測量邊框內部的區域," +"``'outside'`` 會測量包含邊框的區域,而 ``'ignore'`` 則使用官方的 X 區域。" #: ../../library/tkinter.rst:2998 msgid "" "The container relative to which the widget is placed; it must be the " "widget's parent or a descendant of the parent, and defaults to the parent." msgstr "" +"元件放置所相對的容器;它必須是元件的父元件,或父元件的子代,預設為父元件。" #: ../../library/tkinter.rst:3002 msgid "" ":meth:`place`, :meth:`configure` and :meth:`config` are aliases of :meth:`!" "place_configure`." msgstr "" +":meth:`place`、:meth:`configure` 和 :meth:`config` 是 :meth:`!" +"place_configure` 的別名。" #: ../../library/tkinter.rst:3010 msgid "" "Unmap the widget and remove it from the placement, forgetting its place " "options." -msgstr "" +msgstr "取消映射該元件並將其從放置中移除,並捨棄其 place 選項。" #: ../../library/tkinter.rst:3018 msgid "Return a dictionary of the widget's current place options." -msgstr "" +msgstr "回傳一個字典,內容為該元件目前的 place 選項。" #: ../../library/tkinter.rst:3025 msgid "" "Same as :meth:`Misc.place_slaves`: return the list of widgets placed in this " "widget." -msgstr "" +msgstr "與 :meth:`Misc.place_slaves` 相同:回傳放置在此元件中的元件串列。" #: ../../library/tkinter.rst:3031 msgid "" @@ -4245,22 +4911,24 @@ msgid "" "all widgets (through :class:`Widget`). See also :ref:`tkinter-geometry-" "management`." msgstr "" +"佈局管理器,在容器內以列與欄組成的二維格線排列元件。:class:`!Grid` mix-in 由" +"所有元件(透過 :class:`Widget`)繼承。" #: ../../library/tkinter.rst:3046 msgid "Position the widget in a cell of its container's grid." -msgstr "" +msgstr "將元件放置在其容器格線的某個儲存格中。" #: ../../library/tkinter.rst:3048 msgid "Not to be confused with :meth:`Wm.grid`." -msgstr "" +msgstr "請勿與 :meth:`Wm.grid` 混淆。" #: ../../library/tkinter.rst:3050 msgid "The supported options are:" -msgstr "" +msgstr "支援的選項如下:" #: ../../library/tkinter.rst:3052 msgid "*row*, *column*" -msgstr "" +msgstr "*row*, *column*" #: ../../library/tkinter.rst:3053 msgid "" @@ -4269,18 +4937,21 @@ msgid "" "same :meth:`!grid_configure` call (or ``0``), and *row* defaults to the next " "empty row." msgstr "" +"要放置元件的儲存格所在的列與欄,從 ``0`` 開始計算。*column* 預設為同一次 :" +"meth:`!grid_configure` 呼叫中前一個放置元件之後的欄(或 ``0``),而 *row* 預" +"設為下一個空的列。" #: ../../library/tkinter.rst:3059 msgid "*rowspan*, *columnspan*" -msgstr "" +msgstr "*rowspan*, *columnspan*" #: ../../library/tkinter.rst:3060 msgid "The number of rows and columns the widget should span (default ``1``)." -msgstr "" +msgstr "元件應跨越的列數與欄數(預設為 ``1``)。" #: ../../library/tkinter.rst:3062 msgid "*sticky*" -msgstr "" +msgstr "*sticky*" #: ../../library/tkinter.rst:3063 msgid "" @@ -4291,33 +4962,41 @@ msgid "" "fill the height (or width) of the cell. The default is ``''``, which centers " "the widget at its requested size." msgstr "" +"當儲存格大於元件時,如何定位或伸展元件:一個包含零或多個字元 ``'n'``、" +"``'s'``、``'e'`` 和 ``'w'`` 的字串,用以命名元件所貼齊的儲存格邊。同時指定 " +"``'n'`` 和 ``'s'``\\ (或 ``'e'`` 和 ``'w'``)會將元件伸展以填滿儲存格的高度" +"(或寬度)。預設值為 ``''``,此時元件會以其所要求的大小置中。" #: ../../library/tkinter.rst:3081 msgid "" "The container in whose grid to place the widget; it defaults to the parent " "widget." -msgstr "" +msgstr "要在其格線中放置元件的容器;預設為父元件。" #: ../../library/tkinter.rst:3084 msgid "" ":meth:`grid`, :meth:`configure` and :meth:`config` are aliases of :meth:`!" "grid_configure`." msgstr "" +":meth:`grid`、:meth:`configure` 和 :meth:`config` 是 :meth:`!grid_configure` " +"的別名。" #: ../../library/tkinter.rst:3092 msgid "" "Unmap the widget and remove it from the grid, forgetting its grid options." -msgstr "" +msgstr "取消映射該元件並將其從格線中移除,並捨棄其 grid 選項。" #: ../../library/tkinter.rst:3097 msgid "" "Unmap the widget and remove it from the grid, but remember its grid options " "so that it is restored to the same cell if it is gridded again." msgstr "" +"取消映射該元件並將其從格線中移除,但保留其 grid 選項,以便再次進行 grid 設定" +"時可還原到相同的儲存格。" #: ../../library/tkinter.rst:3105 msgid "Return a dictionary of the widget's current grid options." -msgstr "" +msgstr "回傳一個字典,內容為該元件目前的 grid 選項。" #: ../../library/tkinter.rst:3112 msgid "" @@ -4327,6 +5006,10 @@ msgid "" "Treeview `, which provide their own :meth:`!bbox` " "method." msgstr "" +"與 :meth:`Misc.grid_bbox` 相同。:meth:`bbox` 是 :meth:`!grid_bbox` 的別名," +"但 :class:`Canvas`、:class:`Listbox`、:class:`Spinbox`、:class:`Text`、:" +"class:`ttk.Entry ` 和 :class:`ttk.Treeview ` 除外,這些元件提供了自己的 :meth:`!bbox` 方法。" #: ../../library/tkinter.rst:3124 msgid "" @@ -4334,12 +5017,17 @@ msgid "" "*weight*, *minsize*, *pad* and *uniform*) of a grid column. :meth:" "`columnconfigure` is an alias of :meth:`!grid_columnconfigure`." msgstr "" +"與 :meth:`Misc.grid_columnconfigure` 相同:查詢或設定格線欄的選項(例如 " +"*weight*、*minsize*、*pad* 和 *uniform*)。:meth:`columnconfigure` 是 :meth:" +"`!grid_columnconfigure` 的別名。" #: ../../library/tkinter.rst:3133 msgid "" "Same as :meth:`Misc.grid_rowconfigure`: query or set the options of a grid " "row. :meth:`rowconfigure` is an alias of :meth:`!grid_rowconfigure`." msgstr "" +"與 :meth:`Misc.grid_rowconfigure` 相同:查詢或設定格線列的選項。:meth:" +"`rowconfigure` 是 :meth:`!grid_rowconfigure` 的別名。" #: ../../library/tkinter.rst:3142 msgid "" @@ -4347,6 +5035,8 @@ msgid "" "that covers the pixel at *x*, *y*. :meth:`location` is an alias of :meth:`!" "grid_location`." msgstr "" +"與 :meth:`Misc.grid_location` 相同:回傳涵蓋位於 *x*、*y* 像素之儲存格的 " +"``(column, row)``。:meth:`location` 是 :meth:`!grid_location` 的別名。" #: ../../library/tkinter.rst:3151 msgid "" @@ -4354,16 +5044,21 @@ msgid "" "the size of the grid. :meth:`size` is an alias of :meth:`!grid_size`, except " "on the :class:`Listbox` widget, which provides its own :meth:`!size` method." msgstr "" +"與 :meth:`Misc.grid_size` 相同:回傳一個 ``(columns, rows)`` 元組,給出格線的" +"大小。:meth:`size` 是 :meth:`!grid_size` 的別名,但 :class:`Listbox` 元件除" +"外,它提供了自己的 :meth:`!size` 方法。" #: ../../library/tkinter.rst:3164 msgid "Same as :meth:`Misc.grid_propagate`." -msgstr "" +msgstr "與 :meth:`Misc.grid_propagate` 相同。" #: ../../library/tkinter.rst:3171 msgid "" "Same as :meth:`Misc.grid_slaves`: return the widgets managed in the grid, " "optionally restricted to a *row* and/or *column*." msgstr "" +"與 :meth:`Misc.grid_slaves` 相同:回傳在格線中被管理的元件,可選擇限制於特定" +"的 *row* 和/或 *column*。" #: ../../library/tkinter.rst:3177 msgid "" @@ -4372,6 +5067,9 @@ msgid "" "class:`Spinbox`. A widget's :meth:`xview` method is registered as the " "*command* of a horizontal :class:`Scrollbar`." msgstr "" +"提供水平捲動介面的 mix-in,由 :class:`Entry`、:class:`Canvas`、:class:" +"`Listbox`、:class:`Text` 和 :class:`Spinbox` 等元件共用。元件的 :meth:" +"`xview` 方法會被註冊為水平 :class:`Scrollbar` 的 *command*。" #: ../../library/tkinter.rst:3185 msgid "" @@ -4382,12 +5080,18 @@ msgid "" "scrollbar; :meth:`xview_moveto` and :meth:`xview_scroll` provide a more " "convenient interface." msgstr "" +"查詢或變更視圖的水平位置。若不帶引數,則回傳一個由介於 0 和 1 之間的兩個分數" +"組成的元組 ``(first, last)``,表示目前可見的文件部分。否則,引數會被傳遞給 " +"Tk 的 ``xview`` 元件指令,通常由捲軸產生;:meth:`xview_moveto` 和 :meth:" +"`xview_scroll` 提供了更方便的介面。" #: ../../library/tkinter.rst:3195 msgid "" "Adjust the view so that *fraction* of the total width of the document is off-" "screen to the left. *fraction* is a number between 0 and 1." msgstr "" +"調整視圖,使文件總寬度中 *fraction* 的部分位於畫面左側之外。*fraction* 是一個" +"介於 0 和 1 之間的數字。" #: ../../library/tkinter.rst:3201 msgid "" @@ -4395,6 +5099,8 @@ msgid "" "or ``'pages'``; a negative *number* scrolls left and a positive one scrolls " "right." msgstr "" +"將視圖向左或向右移動 *number* 個單位。*what* 為 ``'units'`` 或 ``'pages'`` 其" +"中之一;*number* 為負數時向左捲動,為正數時向右捲動。" #: ../../library/tkinter.rst:3208 msgid "" @@ -4402,6 +5108,9 @@ msgid "" "class:`Canvas`, :class:`Listbox` and :class:`Text`. A widget's :meth:`yview` " "method is registered as the *command* of a vertical :class:`Scrollbar`." msgstr "" +"提供垂直捲動介面的 mix-in,由 :class:`Canvas`、:class:`Listbox` 和 :class:" +"`Text` 等元件共用。元件的 :meth:`yview` 方法會被註冊為垂直 :class:" +"`Scrollbar` 的 *command*。" #: ../../library/tkinter.rst:3215 msgid "" @@ -4412,18 +5121,26 @@ msgid "" "scrollbar; :meth:`yview_moveto` and :meth:`yview_scroll` provide a more " "convenient interface." msgstr "" +"查詢或變更視圖的垂直位置。若不帶引數,則回傳一個由介於 0 和 1 之間的兩個分數" +"組成的元組 ``(first, last)``,表示目前可見的文件部分。否則,引數會被傳遞給 " +"Tk 的 ``yview`` 元件指令,通常由捲軸產生;:meth:`yview_moveto` 和 :meth:" +"`yview_scroll` 提供了更方便的介面。" #: ../../library/tkinter.rst:3225 msgid "" "Adjust the view so that *fraction* of the total height of the document is " "off-screen above the top. *fraction* is a number between 0 and 1." msgstr "" +"調整視圖,使文件總高度中 *fraction* 的部分位於畫面頂端之外。*fraction* 是一個" +"介於 0 和 1 之間的數字。" #: ../../library/tkinter.rst:3231 msgid "" "Shift the view up or down by *number* units. *what* is either ``'units'`` or " "``'pages'``; a negative *number* scrolls up and a positive one scrolls down." msgstr "" +"將視圖向上或向下移動 *number* 個單位。*what* 為 ``'units'`` 或 ``'pages'`` 其" +"中之一;*number* 為負數時向上捲動,為正數時向下捲動。" #: ../../library/tkinter.rst:3238 msgid "" @@ -4432,12 +5149,15 @@ msgid "" "normally uses :class:`Widget` or a concrete widget class rather than " "instantiating :class:`!BaseWidget` directly." msgstr "" +"所有元件的內部基礎類別。它繼承自 :class:`Misc`,並加入用於建立底層 Tk 元件的" +"機制;應用程式程式碼通常會使用 :class:`Widget` 或具體的元件類別,而不會直接實" +"例化 :class:`!BaseWidget`。" #: ../../library/tkinter.rst:3246 msgid "" "Destroy this widget and all of its children, removing the corresponding Tk " "widgets and deleting the associated Tcl commands." -msgstr "" +msgstr "摧毀此元件及其所有子代,移除對應的 Tk 元件並刪除相關聯的 Tcl 指令。" #: ../../library/tkinter.rst:3252 msgid "" @@ -4447,14 +5167,16 @@ msgid "" "geometry managers. The concrete widget classes (:class:`Button`, :class:" "`Label`, and so on) derive from :class:`!Widget`." msgstr "" +"標準元件的內部基礎類別。它結合了 :class:`BaseWidget` 與佈局管理器的 mix-in 類" +"別 :class:`Pack`、:class:`Place` 和 :class:`Grid`,使得每個元件都能由這三種佈" +"局管理器中的任何一種來管理。具體的元件類別(:class:`Button`、:class:`Label` " +"等)皆衍生自 :class:`!Widget`。" -#: ../../library/tkinter.rst:3261 -#, fuzzy +#: ../../library/tkinter.rst:3209 msgid "Toplevel widgets" -msgstr "事件(元件)" +msgstr "頂層元件" -#: ../../library/tkinter.rst:3265 -#, fuzzy +#: ../../library/tkinter.rst:3213 msgid "" "Construct a toplevel Tk widget, which is usually the main window of an " "application, and initialize a Tcl interpreter for this widget. Each " @@ -4462,13 +5184,15 @@ msgid "" "and :class:`Wm`." msgstr "" "建構一個頂層 Tk 元件,它通常是應用程式的主視窗,並為此元件初始化一個 Tcl 直譯" -"器。每個實例都有其自己關聯的 Tcl 直譯器。" +"器。每個實例都有其自己關聯的 Tcl 直譯器。繼承自 :class:`Misc` 和 :class:" +"`Wm`。" #: ../../library/tkinter.rst:3270 msgid "" "To create a Tcl interpreter without initializing the Tk subsystem, use the :" "func:`Tcl` factory function instead." msgstr "" +"若要建立一個不初始化 Tk 子系統的 Tcl 直譯器,請改用 :func:`Tcl` 工廠函式。" #: ../../library/tkinter.rst:3273 msgid "" @@ -4580,6 +5304,10 @@ msgid "" "`USERPROFILE`, or ``c:\\``). This is done by Tcl and can affect other code " "that reads :envvar:`HOME`." msgstr "" +"在 Windows 上,建立 Tcl 直譯器(透過實例化 :class:`Tk` 或呼叫 :func:`Tcl`)" +"時,若處理程序的 :envvar:`HOME` 環境變數尚未設定,則會將其設定為 " +"``%HOMEDRIVE%%HOMEPATH%``\\ (或 :envvar:`USERPROFILE`,或 ``c:\\``)。這是" +"由 Tcl 所執行的操作,可能會影響其他讀取 :envvar:`HOME` 的程式碼。" #: ../../library/tkinter.rst:3318 msgid "" @@ -4619,6 +5347,7 @@ msgid "" "Destroy this and all descendant widgets and, for the main window, end the " "connection to the underlying Tcl interpreter." msgstr "" +"摧毀此元件及所有子代元件,並且對於主視窗而言,會結束與底層 Tcl 直譯器的連線。" #: ../../library/tkinter.rst:3348 msgid "" @@ -4626,6 +5355,8 @@ msgid "" "the interpreter was created without Tk (for example through :func:`Tcl`); it " "is called automatically when *useTk* is true." msgstr "" +"完成 Tk 子系統的載入與初始化。僅當直譯器是在未載入 Tk 的情況下建立時(例如透" +"過 :func:`Tcl`)才需要此操作;當 *useTk* 為 true 時,會自動呼叫此方法。" #: ../../library/tkinter.rst:3355 msgid "" @@ -4647,6 +5378,10 @@ msgid "" "overridden to customize error handling, for example to display the traceback " "in a dialog." msgstr "" +"回報一個回呼例外。當例外從 Tkinter 回呼中傳播出來時,會呼叫此方法;*exc*、" +"*val* 和 *tb* 分別是 :func:`sys.exc_info` 所回傳的例外類型、值和回溯資訊。預" +"設實作會將回溯資訊印到 :data:`sys.stderr`。可以覆寫此方法以自訂錯誤處理方式," +"例如在對話方塊中顯示回溯資訊。" #: ../../library/tkinter.rst:3374 msgid "" @@ -4660,10 +5395,16 @@ msgid "" "manager. Refer to the Tk ``toplevel`` manual page for the full list of " "options." msgstr "" +":class:`!Toplevel` 元件是一個頂層視窗,類似於 :class:`Frame`,但差異在於其 X " +"parent 是螢幕的根視窗,而非其邏輯上的 parent。它主要的用途是作為對話方塊與其" +"他元件集合的容器;其唯一可見的特徵是背景以及可選的立體邊框。值得注意的選項包" +"括 *menu*,用於安裝一個 :class:`Menu` 作為視窗的選單列。繼承自 :class:" +"`BaseWidget` 和 :class:`Wm`,因此頂層視窗會由視窗管理器所管理。完整的選項清單" +"請參閱 Tk ``toplevel`` 手冊頁面。" #: ../../library/tkinter.rst:3388 msgid "Widget classes" -msgstr "" +msgstr "元件類別" #: ../../library/tkinter.rst:3392 msgid "" @@ -4675,6 +5416,11 @@ msgid "" "as *command* (the callback invoked when the button is pressed), " "*textvariable*, *state* and *default*." msgstr "" +":class:`!Button` 元件會顯示文字字串、點陣圖或影像,並在使用者按下它時(透過在" +"按鈕上按下滑鼠按鍵 1,或者當按鈕擁有焦點時按下空白鍵)呼叫一個命令。繼承自 :" +"class:`Widget`。除了標準元件選項之外,按鈕還接受 Tk ``button`` 手冊頁面中所記" +"載的選項,例如 *command*\\ (按下按鈕時所呼叫的回呼函式)、*textvariable*、" +"*state* 和 *default*。" #: ../../library/tkinter.rst:3402 msgid "" @@ -4682,6 +5428,8 @@ msgid "" "its result, or an empty string if no command is associated with the button. " "This is ignored if the button's state is ``disabled``." msgstr "" +"呼叫與按鈕相關聯的命令(如果有的話),並回傳其結果;若沒有與按鈕相關聯的命" +"令,則回傳空字串。若按鈕的狀態為 ``disabled``,則會忽略此操作。" #: ../../library/tkinter.rst:3409 msgid "" @@ -4690,6 +5438,9 @@ msgid "" "same normal or active state as when the method was called. This is ignored " "if the button's state is ``disabled``." msgstr "" +"讓按鈕閃爍:重複顯示按鈕數次,在 active 顏色與 normal 顏色之間交替。閃爍結束" +"後,按鈕會保持在呼叫此方法時所處的 normal 或 active 狀態。若按鈕的狀態為 " +"``disabled``,則會忽略此操作。" #: ../../library/tkinter.rst:3418 msgid "" @@ -4701,6 +5452,12 @@ msgid "" "meth:`~XView.xview` and :meth:`~YView.yview`. Refer to the Tk ``canvas`` " "manual page for the full list of widget and item options." msgstr "" +":class:`!Canvas` 元件實作結構化繪圖。它可以顯示任意數量的\\ *項目*,例如弧" +"形、線條、橢圓形、多邊形、矩形、文字、點陣圖、影像和嵌入的視窗,這些項目可以" +"被繪製、移動、重新著色,並繫結到事件。繼承自 :class:`Widget`、:class:`XView` " +"和 :class:`YView`,因此可以使用 :meth:`~XView.xview` 和 :meth:`~YView.yview` " +"對視圖進行水平和垂直捲動。完整的元件與項目選項清單請參閱 Tk ``canvas`` 手冊頁" +"面。" #: ../../library/tkinter.rst:3428 msgid "" @@ -4717,6 +5474,14 @@ msgid "" "*tagOrId* matching several items, it normally uses the lowest matching item " "in the display list." msgstr "" +"每個項目都有一個在建立時指定的唯一整數 *id*,以及零個或多個字串 *tags* (標" +"籤)。標籤是一個不具整數形式的任意字串;相同的標籤可以由多個項目共用,這使得" +"標籤便於將項目分組。特殊標籤 ``'all'`` 會比對畫布中的每個項目,而 " +"``'current'`` 會比對滑鼠指標下方最頂層的項目。大多數方法都接受一個 *tagOrId* " +"引數,它可以是指定單一項目的整數 id,或是指定零個或多個項目的標籤;如 Tk " +"``canvas`` 手冊頁面所述,標籤也可以是由運算子 ``&&``、``||``、``^``、``!`` 及" +"括號組合而成的標籤邏輯運算式。當作用於單一項目的方法被賦予一個比對多個項目的 " +"*tagOrId* 時,通常會使用顯示清單中最低的相符項目。" #: ../../library/tkinter.rst:3443 msgid "" @@ -4725,6 +5490,9 @@ msgid "" "placed at the top of the list; the order can be changed with :meth:" "`tag_raise` and :meth:`tag_lower`." msgstr "" +"這些項目被保存在一個決定繪製順序的\\ *顯示清單*\\ 中:清單中較後面的項目會被" +"繪製在較前面的項目之上。新建立的項目會被放置在清單的最上方;可以使用 :meth:" +"`tag_raise` 和 :meth:`tag_lower` 來變更順序。" #: ../../library/tkinter.rst:3458 msgid "" @@ -4738,6 +5506,12 @@ msgid "" "centimetres, inches or printer's points), but are always stored and returned " "in pixels." msgstr "" +"建立一個對應類型的新項目並回傳其整數 id。每個方法都以 " +"``create_TYPE(coord..., **options)`` 的形式呼叫:前面的位置引數提供定義該項目" +"的座標(可以是各自獨立的數字、單一數字序列,或座標對),而關鍵字引數則設定該" +"項目特有的選項。座標與螢幕距離可以用數字表示(會被解讀為像素),也可以用帶有" +"單位後綴的字串表示(``'m'``、``'c'``、``'i'`` 或 ``'p'``,分別代表毫米、公" +"分、英寸或印刷的點),但一律以像素儲存並回傳。" #: ../../library/tkinter.rst:3468 msgid "" @@ -4753,6 +5527,14 @@ msgid "" "widget embedded in the canvas at a point ``x, y``, specified with the " "*window* option)." msgstr "" +"項目類型有:``arc``\\ (弧形,是橢圓的一部分,由外接矩形兩個對角的角 ``x1, " +"y1, x2, y2`` 定義);``bitmap``\\ (定位於點 ``x, y`` 的雙色點陣圖);" +"``image``\\ (定位於點 ``x, y`` 的 Tk 影像);``line``\\ (通過點 ``x1, " +"y1, ..., xn, yn`` 的線條或曲線);``oval``\\ (內接於矩形 ``x1, y1, x2, y2`` " +"的圓形或橢圓形);``polygon``\\ (通過點 ``x1, y1, ..., xn, yn`` 的封閉多邊" +"形);``rectangle``\\ (角為 ``x1, y1, x2, y2`` 的矩形);``text``\\ (定位於" +"點 ``x, y`` 的文字字串);以及 ``window``\\ (以 *window* 選項指定、嵌入畫布" +"中點 ``x, y`` 的子元件)。" #: ../../library/tkinter.rst:3480 msgid "" @@ -4760,10 +5542,12 @@ msgid "" "options specific to each type. Option names are passed as keyword arguments, " "without the leading hyphen." msgstr "" +"大多數項目類型都接受一組共通的\\ *標準項目選項*,再加上少數幾個每種類型特有的" +"選項。選項名稱以關鍵字引數的形式傳遞,不含開頭的連字號。" #: ../../library/tkinter.rst:3485 msgid "The standard item options are:" -msgstr "" +msgstr "標準項目選項如下:" #: ../../library/tkinter.rst:3488 msgid "" @@ -4771,15 +5555,17 @@ msgid "" "characters of a *text* item. An empty string (the default for all types " "except *line* and *text*) leaves the item unfilled." msgstr "" +"用於填滿項目內部的顏色,或用於繪製 *line* 項目或 *text* 項目的字元。空字串" +"(除 *line* 和 *text* 外,其他所有類型的預設值)會使項目保持未填滿的狀態。" #: ../../library/tkinter.rst:3493 msgid "*outline*" -msgstr "" +msgstr "*outline*" #: ../../library/tkinter.rst:3494 msgid "" "The color used to draw the item's outline. An empty string draws no outline." -msgstr "" +msgstr "用於繪製項目外框的顏色。空字串則不繪製外框。" #: ../../library/tkinter.rst:3497 ../../library/tkinter.rst:3601 msgid "*width*" @@ -4789,11 +5575,11 @@ msgstr "*width*" msgid "" "The width of the outline, defaulting to ``1.0``. Has no effect if *outline* " "is empty." -msgstr "" +msgstr "外框的寬度,預設為 ``1.0``。若 *outline* 為空,則此選項無效。" #: ../../library/tkinter.rst:3501 msgid "*dash*" -msgstr "" +msgstr "*dash*" #: ../../library/tkinter.rst:3502 msgid "" @@ -4802,40 +5588,45 @@ msgid "" "``'-'``, ``'_'`` and space. An empty pattern (the default) draws a solid " "outline." msgstr "" +"外框的虛線圖樣,可以用以像素為單位的線段長度序列給定,也可以用由字元 " +"``'.'``、``','``、``'-'``、``'_'`` 和空格組成的字串給定。空圖樣(預設值)會繪" +"製實線外框。" #: ../../library/tkinter.rst:3507 msgid "*dashoffset*" -msgstr "" +msgstr "*dashoffset*" #: ../../library/tkinter.rst:3508 msgid "" "The starting offset in pixels into the *dash* pattern. Ignored if there is " "no *dash* pattern." msgstr "" +"進入 *dash* 圖樣的起始偏移量,以像素為單位。若沒有 *dash* 圖樣,則此選項會被" +"忽略。" #: ../../library/tkinter.rst:3511 msgid "*stipple*" -msgstr "" +msgstr "*stipple*" #: ../../library/tkinter.rst:3512 msgid "" "A bitmap used as a stipple pattern when filling the item. Only well " "supported on X11." -msgstr "" +msgstr "填滿項目時用作點狀圖樣的點陣圖。僅在 X11 上有良好的支援。" #: ../../library/tkinter.rst:3515 msgid "*outlinestipple*" -msgstr "" +msgstr "*outlinestipple*" #: ../../library/tkinter.rst:3516 msgid "" "A bitmap used as a stipple pattern when drawing the outline. Has no effect " "if *outline* is empty." -msgstr "" +msgstr "繪製外框時用作點狀圖樣的點陣圖。若 *outline* 為空,則此選項無效。" #: ../../library/tkinter.rst:3519 msgid "*offset*, *outlineoffset*" -msgstr "" +msgstr "*offset*, *outlineoffset*" #: ../../library/tkinter.rst:3520 msgid "" @@ -4843,6 +5634,8 @@ msgid "" "as a side such as ``'n'``, ``'se'`` or ``'center'``. Stipple offsets are " "only supported on X11." msgstr "" +"填色與外框點狀圖樣的偏移量,可以用 ``'x,y'`` 給定,也可以用方位表示,例如 " +"``'n'``、``'se'`` 或 ``'center'``。點狀圖樣的偏移量僅在 X11 上受支援。" #: ../../library/tkinter.rst:3524 ../../library/tkinter.rst:4474 msgid "*state*" @@ -4853,16 +5646,17 @@ msgid "" "Overrides the canvas state for this item; one of ``'normal'``, " "``'disabled'`` or ``'hidden'``." msgstr "" +"覆寫此項目的畫布狀態;為 ``'normal'``、``'disabled'`` 或 ``'hidden'`` 之一。" #: ../../library/tkinter.rst:3528 msgid "*tags*" -msgstr "" +msgstr "*tags*" #: ../../library/tkinter.rst:3529 msgid "" "A single tag or a sequence of tags to associate with the item, replacing any " "existing tags." -msgstr "" +msgstr "要與項目相關聯的單一標籤或標籤序列,會取代任何現有的標籤。" #: ../../library/tkinter.rst:3532 msgid "" @@ -4872,128 +5666,138 @@ msgid "" "item is the active item (under the mouse pointer) or is in the disabled " "state." msgstr "" +"其中許多選項都有 *active...* 和 *disabled...* 的變體(例如 *activefill*、" +"*disabledfill*、*activewidth*、*disableddash*、*activeoutline*、" +"*disabledstipple*),當項目是 active 項目(位於滑鼠指標下方)或處於 disabled " +"狀態時,會覆寫基本選項。" #: ../../library/tkinter.rst:3538 msgid "The following item types support additional options." -msgstr "" +msgstr "下列項目類型支援額外的選項。" #: ../../library/tkinter.rst:3540 msgid "For ``arc`` items:" -msgstr "" +msgstr "對於 ``arc`` 項目:" #: ../../library/tkinter.rst:3542 msgid "*start*" -msgstr "" +msgstr "*start*" #: ../../library/tkinter.rst:3543 msgid "" "The start of the arc's angular range, in degrees measured counter-clockwise " "from the 3-o'clock position." -msgstr "" +msgstr "弧形角度範圍的起點,以度為單位,從 3 點鐘方向逆時針測量。" #: ../../library/tkinter.rst:3546 msgid "*extent*" -msgstr "" +msgstr "*extent*" #: ../../library/tkinter.rst:3547 msgid "" "The size of the angular range, in degrees counter-clockwise from *start*." -msgstr "" +msgstr "角度範圍的大小,以度為單位,從 *start* 逆時針測量。" #: ../../library/tkinter.rst:3550 msgid "*style*" -msgstr "" +msgstr "*style*" #: ../../library/tkinter.rst:3551 msgid "" "How the arc is drawn: ``'pieslice'`` (the default), ``'chord'`` or ``'arc'``." -msgstr "" +msgstr "弧形的繪製方式:``'pieslice'``\\ (預設)、``'chord'`` 或 ``'arc'``。" #: ../../library/tkinter.rst:3554 msgid "For ``line`` items:" -msgstr "" +msgstr "對於 ``line`` 項目:" #: ../../library/tkinter.rst:3556 msgid "*arrow*" -msgstr "" +msgstr "*arrow*" #: ../../library/tkinter.rst:3557 msgid "" "Where to draw arrowheads: ``'none'`` (the default), ``'first'``, ``'last'`` " "or ``'both'``." msgstr "" +"箭頭繪製的位置:``'none'``\\ (預設)、``'first'``、``'last'`` 或 " +"``'both'``。" #: ../../library/tkinter.rst:3560 msgid "*arrowshape*" -msgstr "" +msgstr "*arrowshape*" #: ../../library/tkinter.rst:3561 msgid "A sequence of three distances describing the shape of the arrowheads." -msgstr "" +msgstr "由三個距離組成的序列,用以描述箭頭的形狀。" #: ../../library/tkinter.rst:3564 msgid "*capstyle*" -msgstr "" +msgstr "*capstyle*" #: ../../library/tkinter.rst:3565 msgid "" "How line ends are drawn: ``'butt'`` (the default), ``'projecting'`` or " "``'round'``." msgstr "" +"線條端點的繪製方式:``'butt'``\\ (預設)、``'projecting'`` 或 ``'round'``。" #: ../../library/tkinter.rst:3568 msgid "*joinstyle*" -msgstr "" +msgstr "*joinstyle*" #: ../../library/tkinter.rst:3569 msgid "" "How line vertices are drawn: ``'round'`` (the default), ``'bevel'`` or " "``'miter'``." msgstr "" +"線條頂點的繪製方式:``'round'``\\ (預設)、``'bevel'`` 或 ``'miter'``。" #: ../../library/tkinter.rst:3572 msgid "*smooth*" -msgstr "" +msgstr "*smooth*" #: ../../library/tkinter.rst:3573 msgid "" "The smoothing method: a false value (the default) for no smoothing, or " "``'true'``/``'bezier'`` or ``'raw'`` to draw the line as a curve." msgstr "" +"平滑方法:假值(預設)表示不平滑,或使用 ``'true'``/``'bezier'`` 或 " +"``'raw'`` 將線條繪製為曲線。" #: ../../library/tkinter.rst:3576 msgid "*splinesteps*" -msgstr "" +msgstr "*splinesteps*" #: ../../library/tkinter.rst:3577 msgid "" "The number of line segments approximating each spline when *smooth* is " "enabled." -msgstr "" +msgstr "當 *smooth* 啟用時,用以近似每個雲形線的線段數量。" #: ../../library/tkinter.rst:3580 msgid "For ``polygon`` items:" -msgstr "" +msgstr "對於 ``polygon`` 項目:" #: ../../library/tkinter.rst:3582 msgid "*joinstyle*, *smooth*, *splinesteps*" -msgstr "" +msgstr "*joinstyle*, *smooth*, *splinesteps*" #: ../../library/tkinter.rst:3583 msgid "As for ``line`` items, applied to the polygon's outline." -msgstr "" +msgstr "與 ``line`` 項目相同,套用於多邊形的外框。" #: ../../library/tkinter.rst:3585 msgid "For ``text`` items:" -msgstr "" +msgstr "對於 ``text`` 項目:" #: ../../library/tkinter.rst:3587 msgid "*text*" -msgstr "" +msgstr "*text*" #: ../../library/tkinter.rst:3588 msgid "The string to display; newline characters start new lines." -msgstr "" +msgstr "要顯示的字串;換行字元會開始新的一行。" #: ../../library/tkinter.rst:3590 ../../library/tkinter.rst:4488 #: ../../library/tkinter.rst:5372 @@ -5002,7 +5806,7 @@ msgstr "*font*" #: ../../library/tkinter.rst:3591 msgid "The font used for the text." -msgstr "" +msgstr "文字所使用的字型。" #: ../../library/tkinter.rst:3593 ../../library/tkinter.rst:5412 msgid "*justify*" @@ -5017,34 +5821,36 @@ msgstr "對齊方式:``'left'``\\ (預設)、``'right'`` 或 ``'center'`` #: ../../library/tkinter.rst:3598 msgid "" "How the text is positioned relative to its point, defaulting to ``'center'``." -msgstr "" +msgstr "文字相對於其定位點的位置,預設為 ``'center'``。" #: ../../library/tkinter.rst:3602 msgid "The maximum line length; if non-zero, lines are wrapped at spaces." -msgstr "" +msgstr "每行的最大長度;若非零,則會在空格處換行。" #: ../../library/tkinter.rst:3604 msgid "*angle*" -msgstr "" +msgstr "*angle*" #: ../../library/tkinter.rst:3605 msgid "" "How many degrees to rotate the text counter-clockwise about its positioning " "point, from ``0.0`` to ``360.0`` (default ``0.0``)." msgstr "" +"文字要繞著其定位點逆時針旋轉的角度,範圍從 ``0.0`` 到 ``360.0``\\ (預設為 " +"``0.0``)。" #: ../../library/tkinter.rst:3608 ../../library/tkinter.rst:4470 #: ../../library/tkinter.rst:5397 msgid "*underline*" -msgstr "" +msgstr "*underline*" #: ../../library/tkinter.rst:3609 msgid "The index of a character to underline, or ``-1`` for none." -msgstr "" +msgstr "要加底線的字元索引,或 ``-1`` 表示不加底線。" #: ../../library/tkinter.rst:3611 msgid "For ``bitmap`` items:" -msgstr "" +msgstr "對於 ``bitmap`` 項目:" #: ../../library/tkinter.rst:3613 ../../library/tkinter.rst:4485 msgid "*bitmap*" @@ -5052,15 +5858,15 @@ msgstr "*bitmap*" #: ../../library/tkinter.rst:3614 msgid "The bitmap to display." -msgstr "" +msgstr "要顯示的點陣圖。" #: ../../library/tkinter.rst:3617 msgid "How the bitmap is positioned relative to its point." -msgstr "" +msgstr "點陣圖相對於其定位點的位置。" #: ../../library/tkinter.rst:3619 ../../library/tkinter.rst:4491 msgid "*background*, *foreground*" -msgstr "" +msgstr "*background*, *foreground*" #: ../../library/tkinter.rst:3620 msgid "" @@ -5069,10 +5875,13 @@ msgid "" "*disabled...* variants, and *bitmap* has *activebitmap* and *disabledbitmap* " "variants." msgstr "" +"用於點陣圖 ``0`` 和 ``1`` 像素的顏色;若 *background* 為空,則 ``0`` 像素會變" +"成透明。這兩者都有 *active...* 和 *disabled...* 的變體,而 *bitmap* 則有 " +"*activebitmap* 和 *disabledbitmap* 的變體。" #: ../../library/tkinter.rst:3625 msgid "For ``image`` items:" -msgstr "" +msgstr "對於 ``image`` 項目:" #: ../../library/tkinter.rst:3627 ../../library/tkinter.rst:4477 msgid "*image*" @@ -5080,53 +5889,58 @@ msgstr "*image*" #: ../../library/tkinter.rst:3628 msgid "The Tk image to display, previously created with the image protocols." -msgstr "" +msgstr "要顯示的 Tk 影像,須事先使用影像協定建立。" #: ../../library/tkinter.rst:3632 msgid "How the image is positioned relative to its point." -msgstr "" +msgstr "影像相對於其定位點的位置。" #: ../../library/tkinter.rst:3634 msgid "" "Both options have *active...* and *disabled...* variants (*activeimage*, " "*disabledimage*) used in the active and disabled states." msgstr "" +"這兩個選項都有 *active...* 和 *disabled...* 的變體(*activeimage*、" +"*disabledimage*),用於 active 和 disabled 狀態。" #: ../../library/tkinter.rst:3638 msgid "For ``window`` items:" -msgstr "" +msgstr "對於 ``window`` 項目:" #: ../../library/tkinter.rst:3640 msgid "*window*" -msgstr "" +msgstr "*window*" #: ../../library/tkinter.rst:3641 msgid "" "The widget to embed; it must be a child of the canvas or of one of its " "ancestors, and may not be a top-level window." -msgstr "" +msgstr "要嵌入的元件;它必須是畫布或其某個祖先的子代,且不可為頂層視窗。" #: ../../library/tkinter.rst:3645 msgid "How the window is positioned relative to its point." -msgstr "" +msgstr "視窗相對於其定位點的位置。" #: ../../library/tkinter.rst:3648 msgid "" "The size to assign to the window; if zero (the default), the window is given " "its requested size." -msgstr "" +msgstr "要指定給視窗的大小;若為零(預設值),則視窗會使用其所要求的大小。" #: ../../library/tkinter.rst:3651 msgid "" "``oval`` and ``rectangle`` items have no type-specific options; they use " "only the standard item options." msgstr "" +"``oval`` 和 ``rectangle`` 項目沒有類型特有的選項;它們只使用標準項目選項。" #: ../../library/tkinter.rst:3656 msgid "" "Tk 8.6 added the *angle* option and Tk 9.0 added the *underline* option for " "``text`` items." msgstr "" +"Tk 8.6 為 ``text`` 項目新增了 *angle* 選項,Tk 9.0 則新增了 *underline* 選" +"項。" #: ../../library/tkinter.rst:3663 msgid "" @@ -5139,6 +5953,11 @@ msgid "" "of the units used to specify them; for rectangles, ovals and arcs they are " "ordered left, top, right, bottom." msgstr "" +"查詢或修改項目的座標。若只給定 *tagOrId*,則回傳由 *tagOrId* 所指定項目(若比" +"對到多個項目,則為第一個相符的項目)的浮點數座標串列。若給定新的座標,則會以" +"這些座標取代該項目的座標;與 ``create_*`` 方法相同,座標可以用各自獨立的數" +"字、單一序列,或座標對來給定。回傳的座標一律以像素表示,不論指定時所使用的單" +"位為何;對於矩形、橢圓形和弧形,座標的順序為左、上、右、下。" #: ../../library/tkinter.rst:3674 msgid "" @@ -5146,6 +5965,8 @@ msgid "" "arguments, as a single sequence, or grouped in pairs, like the ``create_*`` " "methods." msgstr "" +"現在引數會被扁平化:座標可以用各自獨立的引數、單一序列,或成對分組來給定,與 " +"``create_*`` 方法相同。" #: ../../library/tkinter.rst:3682 msgid "" @@ -5153,6 +5974,8 @@ msgid "" "adding *xAmount* to every x-coordinate and *yAmount* to every y-coordinate " "of the item." msgstr "" +"在畫布座標空間中移動由 *tagOrId* 指定的每個項目:將 *xAmount* 加到項目的每個 " +"x 座標,並將 *yAmount* 加到每個 y 座標。" #: ../../library/tkinter.rst:3688 msgid "" @@ -5162,6 +5985,9 @@ msgid "" "corresponding coordinate is unchanged. All matching items keep their " "positions relative to each other." msgstr "" +"移動由 *tagOrId* 指定的項目,使最低相符項目的第一個座標對(邊界框的左上角)位" +"於位置 (*x*, *y*)。*x* 或 *y* 可以是空字串,此時對應的座標維持不變。所有相符" +"的項目會保持彼此的相對位置。" #: ../../library/tkinter.rst:3700 msgid "" @@ -5171,10 +5997,14 @@ msgid "" "from *yOrigin* changes by a factor of *yScale* (a factor of ``1.0`` leaves " "the coordinate unchanged)." msgstr "" +"在畫布座標空間中,重新縮放由 *tagOrId* 指定的所有項目的座標。每個 x 座標都會" +"被調整,使其與 *xOrigin* 的距離按 *xScale* 的倍率變化;每個 y 座標則會被調" +"整,使其與 *yOrigin* 的距離按 *yScale* 的倍率變化(倍率為 ``1.0`` 時座標維持" +"不變)。" #: ../../library/tkinter.rst:3709 msgid "Delete each of the items given by the *tagOrIds* arguments." -msgstr "" +msgstr "刪除由 *tagOrIds* 引數指定的每個項目。" #: ../../library/tkinter.rst:3714 msgid "" @@ -5183,6 +6013,9 @@ msgid "" "to *last* inclusive; *last* defaults to *first*. Items that do not support " "indexing ignore this operation." msgstr "" +"從由 *tagOrId* 指定的每個項目中,刪除從 *first* 到 *last* (含)範圍內的字元" +"(對 text 項目而言)或座標(對 line 和 polygon 項目而言);*last* 預設為 " +"*first*。不支援索引的項目會忽略此操作。" #: ../../library/tkinter.rst:3721 msgid "" @@ -5190,6 +6023,8 @@ msgid "" "character or coordinate whose index is *beforeThis*. For line and polygon " "items *string* must be a valid sequence of coordinates." msgstr "" +"將 *string* 插入由 *tagOrId* 指定的每個項目中,插在索引為 *beforeThis* 的字元" +"或座標之前。對於 line 和 polygon 項目,*string* 必須是有效的座標序列。" #: ../../library/tkinter.rst:3728 msgid "" @@ -5197,6 +6032,8 @@ msgid "" "given by *tagOrId* (the lowest matching item if it matches several). This is " "like :meth:`~Misc.cget` but applies to an individual item." msgstr "" +"回傳由 *tagOrId* 指定項目(若比對到多個項目,則為最低的相符項目)的設定選項 " +"*option* 目前的值。這類似於 :meth:`~Misc.cget`,但適用於單一項目。" #: ../../library/tkinter.rst:3737 msgid "" @@ -5208,6 +6045,11 @@ msgid "" "options are those accepted by the corresponding ``create_*`` method. :meth:" "`itemconfig` is an alias of :meth:`!itemconfigure`." msgstr "" +"查詢或修改由 *tagOrId* 指定項目的設定選項。這與 :meth:`~Misc.configure` 類" +"似,差別在於它適用於個別項目,而非整個畫布。若不帶選項,則回傳一個描述第一個" +"相符項目目前選項的字典;否則會將給定的選項設定到每個相符的項目上。合法的選項" +"為對應的 ``create_*`` 方法所接受的選項。:meth:`itemconfig` 是 :meth:`!" +"itemconfigure` 的別名。" #: ../../library/tkinter.rst:3750 msgid "" @@ -5215,6 +6057,9 @@ msgid "" "it matches several), such as ``'rectangle'`` or ``'text'``, or ``None`` if " "*tagOrId* does not match any item." msgstr "" +"回傳由 *tagOrId* 指定項目(若比對到多個項目,則為第一個相符的項目)的類型,例" +"如 ``'rectangle'`` 或 ``'text'``;若 *tagOrId* 未比對到任何項目,則回傳 " +"``None``。" #: ../../library/tkinter.rst:3756 msgid "" @@ -5222,12 +6067,16 @@ msgid "" "first matching item in display-list order if it matches several). Return an " "empty tuple if no item matches or the item has no tags." msgstr "" +"回傳與由 *tagOrId* 指定項目相關聯的標籤元組(若比對到多個項目,則依顯示清單順" +"序取第一個相符的項目)。若沒有項目相符,或該項目沒有標籤,則回傳空元組。" #: ../../library/tkinter.rst:3763 msgid "" "Remove the tag *tagToDelete* (which defaults to *tagOrId*) from each of the " "items given by *tagOrId*. Items that do not have that tag are unaffected." msgstr "" +"從 *tagOrId* 所指定的每個項目中移除標籤 *tagToDelete* (預設為 *tagOrId*)。" +"沒有該標籤的項目不受影響。" #: ../../library/tkinter.rst:3769 msgid "" @@ -5237,22 +6086,26 @@ msgid "" "``'withtag'``; the ``addtag_*`` methods below are convenient wrappers that " "supply each of these forms." msgstr "" +"將標籤 *newtag* 加入到搜尋規範 *searchSpec* (以及任何額外的 *args*)所選取的" +"每個項目。*searchSpec* 為 ``'above'``、``'all'``、``'below'``、" +"``'closest'``、``'enclosed'``、``'overlapping'`` 或 ``'withtag'`` 之一;下方" +"的 ``addtag_*`` 方法是提供這些形式的便利包裝函式。" #: ../../library/tkinter.rst:3778 msgid "" "Add the tag *newtag* to the item just above (after) *tagOrId* in the display " "list." -msgstr "" +msgstr "將標籤 *newtag* 加入到顯示清單中緊接在 *tagOrId* 之上(之後)的項目。" #: ../../library/tkinter.rst:3783 msgid "Add the tag *newtag* to all items in the canvas." -msgstr "" +msgstr "將標籤 *newtag* 加入到畫布中的所有項目。" #: ../../library/tkinter.rst:3787 msgid "" "Add the tag *newtag* to the item just below (before) *tagOrId* in the " "display list." -msgstr "" +msgstr "將標籤 *newtag* 加入到顯示清單中緊接在 *tagOrId* 之下(之前)的項目。" #: ../../library/tkinter.rst:3792 msgid "" @@ -5262,22 +6115,30 @@ msgid "" "closest item that lies below *start* in the display list, which can be used " "to step through all the closest items." msgstr "" +"將標籤 *newtag* 加入到最接近點 (*x*, *y*) 的項目。若有給定 *halo*,則該點該距" +"離內的任何項目都會被視為與其重疊。若有給定 *start* (一個標籤或 id),則選擇" +"顯示清單中位於 *start* 之下、最接近該點的最上層項目,這可用於依序走訪所有最接" +"近的項目。" #: ../../library/tkinter.rst:3801 msgid "" "Add the tag *newtag* to every item completely enclosed within the rectangle " "(*x1*, *y1*, *x2*, *y2*), where *x1* <= *x2* and *y1* <= *y2*." msgstr "" +"將標籤 *newtag* 加入到完全被包圍在矩形 (*x1*, *y1*, *x2*, *y2*) 內的每個項" +"目,其中 *x1* <= *x2* 且 *y1* <= *y2*。" #: ../../library/tkinter.rst:3806 msgid "" "Add the tag *newtag* to every item that overlaps or is enclosed within the " "rectangle (*x1*, *y1*, *x2*, *y2*), where *x1* <= *x2* and *y1* <= *y2*." msgstr "" +"將標籤 *newtag* 加入到與矩形 (*x1*, *y1*, *x2*, *y2*) 重疊或被包圍在其中的每" +"個項目,其中 *x1* <= *x2* 且 *y1* <= *y2*。" #: ../../library/tkinter.rst:3812 msgid "Add the tag *newtag* to every item given by *tagOrId*." -msgstr "" +msgstr "將標籤 *newtag* 加入到 *tagOrId* 所指定的每個項目。" #: ../../library/tkinter.rst:3816 msgid "" @@ -5287,45 +6148,54 @@ msgid "" "`addtag`. The ``find_*`` methods below are more convenient wrappers around " "it." msgstr "" +"回傳一個包含由搜尋規範 *searchSpec* (以及任何額外的 *args*)所選取的所有項目" +"id 的元組,依堆疊順序排列,最下層的項目在前。搜尋規範可以是 :meth:`addtag` 所" +"接受的任一形式。下方的 ``find_*`` 方法是圍繞它的更方便的包裝函式。" #: ../../library/tkinter.rst:3824 msgid "" "Return a tuple containing the id of the item just above *tagOrId* in the " "display list." -msgstr "" +msgstr "回傳一個包含顯示清單中緊接在 *tagOrId* 之上的項目 id 的元組。" #: ../../library/tkinter.rst:3829 msgid "" "Return a tuple of the ids of all items in the canvas, in stacking order." -msgstr "" +msgstr "回傳一個包含畫布中所有項目 id 的元組,依堆疊順序排列。" #: ../../library/tkinter.rst:3833 msgid "" "Return a tuple containing the id of the item just below *tagOrId* in the " "display list." -msgstr "" +msgstr "回傳一個包含顯示清單中緊接在 *tagOrId* 之下的項目 id 的元組。" #: ../../library/tkinter.rst:3838 msgid "" "Return a tuple containing the id of the item closest to the point (*x*, " "*y*). *halo* and *start* are interpreted as for :meth:`addtag_closest`." msgstr "" +"回傳一個包含最接近點 (*x*, *y*) 的項目 id 的元組。*halo* 和 *start* 的解讀方" +"式與 :meth:`addtag_closest` 相同。" #: ../../library/tkinter.rst:3844 msgid "" "Return a tuple of the ids of all items completely enclosed within the " "rectangle (*x1*, *y1*, *x2*, *y2*)." msgstr "" +"回傳一個包含完全被包圍在矩形 (*x1*, *y1*, *x2*, *y2*) 內的所有項目 id 的元" +"組。" #: ../../library/tkinter.rst:3849 msgid "" "Return a tuple of the ids of all items that overlap or are enclosed within " "the rectangle (*x1*, *y1*, *x2*, *y2*)." msgstr "" +"回傳一個包含與矩形 (*x1*, *y1*, *x2*, *y2*) 重疊或被包圍在其中的所有項目 id " +"的元組。" #: ../../library/tkinter.rst:3854 msgid "Return a tuple of the ids of all items given by *tagOrId*." -msgstr "" +msgstr "回傳一個包含 *tagOrId* 所指定的所有項目 id 的元組。" #: ../../library/tkinter.rst:3864 msgid "" @@ -5336,6 +6206,11 @@ msgid "" "is controlled by :meth:`Misc.tkraise` and :meth:`Misc.lower` instead. :meth:" "`lift` and :meth:`tkraise` are aliases of :meth:`!tag_raise`." msgstr "" +"將 *tagOrId* 所指定的所有項目移動到顯示清單中緊接在 *aboveThis* 所指定項目之" +"上的新位置,若省略 *aboveThis* 則移動到顯示清單的最上層。當同時移動多個項目" +"時,會保留它們之間的相對順序。這對內嵌視窗項目沒有影響,其堆疊順序改由 :meth:" +"`Misc.tkraise` 和 :meth:`Misc.lower` 控制。:meth:`lift` 和 :meth:`tkraise` " +"是 :meth:`!tag_raise` 的別名。" #: ../../library/tkinter.rst:3877 msgid "" @@ -5345,6 +6220,10 @@ msgid "" "preserved. This has no effect on embedded window items. :meth:`lower` is an " "alias of :meth:`!tag_lower`." msgstr "" +"將 *tagOrId* 所指定的所有項目移動到顯示清單中緊接在 *belowThis* 所指定項目之" +"下的新位置,若省略 *belowThis* 則移動到顯示清單的最下層。當同時移動多個項目" +"時,會保留它們之間的相對順序。這對內嵌視窗項目沒有影響。:meth:`lower` 是 :" +"meth:`!tag_lower` 的別名。" #: ../../library/tkinter.rst:3886 msgid "" @@ -5353,6 +6232,10 @@ msgid "" "and :meth:`Misc.lower` methods that restack the widget itself, which are " "therefore not available." msgstr "" +"在 :class:`Canvas` 上,:meth:`tkraise`/:meth:`lift` 和 :meth:`lower` 會重新排" +"列畫布項目的堆疊順序,這遮蔽了繼承而來、用於重新排列元件本身堆疊順序的 :meth:" +"`Misc.tkraise`/:meth:`Misc.lift` 和 :meth:`Misc.lower` 方法,因此這些方法無法" +"使用。" #: ../../library/tkinter.rst:3894 msgid "" @@ -5366,6 +6249,12 @@ msgid "" "than replacing them. Return the identifier of the bound function, which can " "be passed to :meth:`tag_unbind`." msgstr "" +"將回呼函式 *func* 綁定到 *tagOrId* 所指定的所有項目的事件 *sequence*,使得每" +"當該事件發生在其中一個項目上時就會呼叫 *func*。這類似於 :meth:`Widget.bind " +"`,但作用於畫布項目而非整個元件;只能綁定滑鼠、鍵盤和虛擬事件。滑" +"鼠事件會導向目前項目,鍵盤事件則導向焦點項目(見 :meth:`focus`)。若 *add* 為" +"真,新的綁定會加入到同一事件序列的現有綁定中,而不是取代它們。回傳所綁定函式" +"的識別碼,可將其傳入 :meth:`tag_unbind`。" #: ../../library/tkinter.rst:3909 msgid "" @@ -5373,10 +6262,12 @@ msgid "" "*sequence*. If *funcid* is given, only that callback (as returned by :meth:" "`tag_bind`) is unbound and deregistered." msgstr "" +"為 *tagOrId* 所指定的所有項目移除事件 *sequence* 的綁定。若有給定 *funcid*," +"則只會解除綁定並取消註冊該回呼函式(由 :meth:`tag_bind` 回傳)。" #: ../../library/tkinter.rst:3914 ../../library/tkinter.rst:5518 msgid "If *funcid* is given, only that callback is unbound." -msgstr "" +msgstr "若有給定 *funcid*,則只會解除該回呼函式的綁定。" #: ../../library/tkinter.rst:3920 msgid "" @@ -5386,6 +6277,9 @@ msgid "" "pixels. Return ``None`` if no item matches or the matching items have " "nothing to display." msgstr "" +"回傳一個 4 元組 ``(x1, y1, x2, y2)``,以像素為單位給出包圍 *tagOrId* 及任何其" +"他 *tagOrIds* 所指定的所有項目的近似外框。結果可能會比實際外框多估計幾個像" +"素。若沒有項目匹配,或匹配的項目沒有任何內容可顯示,則回傳 ``None``。" #: ../../library/tkinter.rst:3927 ../../library/tkinter.rst:4320 #: ../../library/tkinter.rst:5061 ../../library/tkinter.rst:5288 @@ -5393,6 +6287,8 @@ msgid "" "This shadows the inherited :meth:`!Misc.bbox`; use :meth:`~Misc.grid_bbox` " "for the grid bounding box." msgstr "" +"這會遮蔽繼承的 :meth:`!Misc.bbox`;請使用 :meth:`~Misc.grid_bbox` 取得網格的" +"外框。" #: ../../library/tkinter.rst:3932 msgid "" @@ -5400,6 +6296,8 @@ msgid "" "displayed at that location. If *gridspacing* is given, the result is rounded " "to the nearest multiple of *gridspacing* units." msgstr "" +"給定一個視窗 x 座標 *screenx*,回傳該位置所顯示的畫布 x 座標。若有給定 " +"*gridspacing*,結果會被四捨五入到最接近的 *gridspacing* 單位倍數。" #: ../../library/tkinter.rst:3939 msgid "" @@ -5407,6 +6305,8 @@ msgid "" "displayed at that location. If *gridspacing* is given, the result is rounded " "to the nearest multiple of *gridspacing* units." msgstr "" +"給定一個視窗 y 座標 *screeny*,回傳該位置所顯示的畫布 y 座標。若有給定 " +"*gridspacing*,結果會被四捨五入到最接近的 *gridspacing* 單位倍數。" #: ../../library/tkinter.rst:3947 msgid "" @@ -5418,12 +6318,19 @@ msgid "" "displays the insertion cursor when both it is the focus item and its canvas " "has the input focus." msgstr "" +"若給定 *tagOrId*,將畫布的鍵盤焦點設定到 *tagOrId* 所指定、且支援插入游標的第" +"一個項目;若不存在這樣的項目,則焦點保持不變。若 *tagOrId* 為空字串,則重設焦" +"點,使得沒有任何項目擁有它。若未給定引數,則回傳目前擁有焦點的項目 id,若沒有" +"則回傳空字串。項目只有在它同時是焦點項目且其畫布擁有輸入焦點時,才會顯示插入" +"游標。" #: ../../library/tkinter.rst:3956 msgid "" "This shadows the inherited :meth:`!Misc.focus`; use :meth:`~Misc.focus_set` " "to focus the widget itself." msgstr "" +"這會遮蔽繼承的 :meth:`!Misc.focus`;請使用 :meth:`~Misc.focus_set` 來讓元件本" +"身取得焦點。" #: ../../library/tkinter.rst:3961 msgid "" @@ -5432,6 +6339,8 @@ msgid "" "are unaffected. The cursor is only displayed when the item has the focus, " "but its position may be set at any time." msgstr "" +"將 *tagOrId* 所指定項目的插入游標設定到 *index* 所指定字元之前。不支援插入游" +"標的項目不受影響。游標只有在項目擁有焦點時才會顯示,但其位置可隨時設定。" #: ../../library/tkinter.rst:3969 msgid "" @@ -5441,6 +6350,9 @@ msgid "" "coordinates). If *tagOrId* matches several items, the first one that " "supports indexing is used." msgstr "" +"以整數形式回傳 *tagOrId* 中對應於 *index* 的數字索引,*index* 是位置的文字描" +"述(對文字項目而言是字元的索引,對線條和多邊形項目而言是座標的索引)。若 " +"*tagOrId* 匹配多個項目,則使用第一個支援索引的項目。" #: ../../library/tkinter.rst:3978 msgid "" @@ -5449,10 +6361,13 @@ msgid "" "`select_to` calls. If the selection is not currently in *tagOrId*, this " "behaves like :meth:`select_to`." msgstr "" +"調整 *tagOrId* 中最接近 *index* 的選取範圍端點,使其位於 *index*,並將另一端" +"設為未來 :meth:`select_to` 呼叫的錨點。若目前 *tagOrId* 中沒有選取範圍,則其" +"行為與 :meth:`select_to` 相同。" #: ../../library/tkinter.rst:3986 msgid "Clear the selection if it is in this canvas; otherwise do nothing." -msgstr "" +msgstr "若選取範圍在此畫布中,則清除該選取範圍;否則不做任何事。" #: ../../library/tkinter.rst:3990 msgid "" @@ -5460,6 +6375,8 @@ msgid "" "in the item given by *tagOrId*. This does not change the selection itself; " "it sets the fixed end for future :meth:`select_to` calls." msgstr "" +"將選取錨點設定到 *tagOrId* 所指定項目中 *index* 所指定字元之前。這不會改變選" +"取範圍本身;它會設定未來 :meth:`select_to` 呼叫的固定端點。" #: ../../library/tkinter.rst:3997 msgid "" @@ -5467,6 +6384,8 @@ msgid "" "selection is not in this canvas. Unlike :meth:`find` and the ``find_*`` " "methods, this returns the id as a string rather than an integer." msgstr "" +"回傳持有選取範圍的項目 id,若此畫布中沒有選取範圍則回傳 ``None``。與 :meth:" +"`find` 及 ``find_*`` 方法不同,此方法回傳的 id 是字串而非整數。" #: ../../library/tkinter.rst:4004 msgid "" @@ -5474,6 +6393,9 @@ msgid "" "anchor point and *index*, inclusive of *index*. The anchor point is the one " "set by the most recent :meth:`select_adjust` or :meth:`select_from` call." msgstr "" +"將選取範圍設定為 *tagOrId* 中選取錨點與 *index* 之間(含 *index*)的字元。錨" +"點是由最近一次 :meth:`select_adjust` 或 :meth:`select_from` 呼叫所設定的錨" +"點。" #: ../../library/tkinter.rst:4011 ../../library/tkinter.rst:4416 #: ../../library/tkinter.rst:5642 @@ -5481,6 +6403,8 @@ msgid "" "Record *x*, *y* and the current view, for use with later :meth:`scan_dragto` " "calls. This is typically bound to a mouse button press in the widget." msgstr "" +"記錄 *x*、*y* 和目前的檢視,供之後的 :meth:`scan_dragto` 呼叫使用。這通常會綁" +"定到元件中的滑鼠按鍵按下事件。" #: ../../library/tkinter.rst:4017 msgid "" @@ -5489,6 +6413,9 @@ msgid "" "bound to mouse motion events in the widget, producing the effect of dragging " "the canvas at high speed through its window." msgstr "" +"將畫布捲動 *gain* 倍於 *x*、*y* 與上一次 :meth:`scan_mark` 呼叫所傳入座標之間" +"的差值。這通常會綁定到元件中的滑鼠移動事件,產生以高速在其視窗中拖曳畫布的效" +"果。" #: ../../library/tkinter.rst:4024 msgid "" @@ -5502,6 +6429,12 @@ msgid "" "*pageanchor*, *pageheight*, *pagewidth*, *pagex*, *pagey*, *rotate*, " "*width*, *x* and *y*." msgstr "" +"產生畫布全部或部分內容的 PostScript(Encapsulated PostScript,3.0 版)表示" +"法。若有給定 *file* 或 *channel* 選項,則會將 PostScript 寫入該處並回傳空字" +"串;否則會以字串形式回傳。預設情況下只會產生目前在視窗中可見的區域,因此通常" +"需要先呼叫 :meth:`~Misc.update`,或使用 *width* 和 *height* 選項。支援的選項" +"包括 *colormap*、*colormode*、*file*、*fontmap*、*height*、*pageanchor*、" +"*pageheight*、*pagewidth*、*pagex*、*pagey*、*rotate*、*width*、*x* 和 *y*。" #: ../../library/tkinter.rst:4039 msgid "" @@ -5515,6 +6448,13 @@ msgid "" "checkbutton accepts the options documented in the Tk ``checkbutton`` manual " "page, such as *variable*, *onvalue*, *offvalue* and *command*." msgstr "" +":class:`!Checkbutton`\\ (核取按鈕)元件會顯示一個文字字串、點陣圖或圖片,並" +"搭配一個方形指示器,按下時會切換一個布林選取狀態。它具有簡單按鈕的所有行為," +"此外還可以被選取:選取時指示器會繪製打勾標記,並將關聯的變數設為 " +"``onvalue``;取消選取時指示器會繪製為空白,並將變數設為 ``offvalue``。繼承" +"自 :class:`Widget`。除了標準元件選項外,核取按鈕還接受 Tk ``checkbutton`` " +"manual page 中所記載的選項,例如 *variable*、*onvalue*、*offvalue* 和 " +"*command*。" #: ../../library/tkinter.rst:4053 msgid "" @@ -5524,22 +6464,25 @@ msgid "" "string if no command is associated with the checkbutton. This is ignored if " "the checkbutton's state is ``disabled``." msgstr "" +"執行使用者以滑鼠按下核取按鈕時會發生的行為:切換按鈕的選取狀態,並呼叫相關聯" +"的命令(如果有的話)。回傳該命令的結果,若核取按鈕沒有關聯的命令則回傳空字" +"串。若核取按鈕的狀態為 ``disabled``,則會忽略此方法。" #: ../../library/tkinter.rst:4062 msgid "" "Select the checkbutton and set the associated variable to its ``onvalue``." -msgstr "" +msgstr "選取核取按鈕,並將相關聯的變數設為其 ``onvalue``。" #: ../../library/tkinter.rst:4067 msgid "" "Deselect the checkbutton and set the associated variable to its ``offvalue``." -msgstr "" +msgstr "取消選取核取按鈕,並將相關聯的變數設為其 ``offvalue``。" #: ../../library/tkinter.rst:4072 msgid "" "Toggle the selection state of the button, redisplaying it and modifying its " "associated variable to reflect the new state." -msgstr "" +msgstr "切換按鈕的選取狀態,重新顯示按鈕,並修改相關聯的變數以反映新的狀態。" #: ../../library/tkinter.rst:4077 msgid "" @@ -5548,6 +6491,9 @@ msgid "" "left in the same normal or active state as when the method was called. This " "is ignored if the checkbutton's state is ``disabled``." msgstr "" +"透過多次重新顯示核取按鈕、在作用中和一般顏色之間交替來閃爍核取按鈕。閃爍結束" +"後,核取按鈕會保持呼叫此方法時原本的一般或作用中狀態。若核取按鈕的狀態為 " +"``disabled``,則會忽略此方法。" #: ../../library/tkinter.rst:4086 msgid "" @@ -5556,6 +6502,9 @@ msgid "" "hold strings too long to fit in the window, they support horizontal " "scrolling through :meth:`~XView.xview`." msgstr "" +":class:`!Entry`\\ (輸入框)元件會顯示單行文字,並讓使用者編輯該文字。繼承" +"自 :class:`Widget` 和 :class:`XView`;由於輸入框中可能包含長度超過視窗的字" +"串,因此它們透過 :meth:`~XView.xview` 支援水平捲動。" #: ../../library/tkinter.rst:4092 msgid "" @@ -5567,6 +6516,11 @@ msgid "" "together let a callback accept or reject edits), and *state* (one of " "``'normal'``, ``'disabled'`` or ``'readonly'``)." msgstr "" +"除了標準元件選項外,輸入框還接受 Tk ``entry`` manual page 中所記載的選項。其" +"中值得注意的有 *textvariable* (與輸入框內容保持同步的變數名稱)、*show* (若" +"有設定,則每個字元都會以指定的字元顯示而非其真實值,適用於密碼輸入)、" +"*validate* 和 *validatecommand* (兩者共同讓回呼函式接受或拒絕編輯),以及 " +"*state* (``'normal'``、``'disabled'`` 或 ``'readonly'`` 之一)。" #: ../../library/tkinter.rst:4101 msgid "" @@ -5579,6 +6533,12 @@ msgid "" "x-coordinate *x* in the window). Out-of-range indices are rounded to the " "nearest legal value." msgstr "" +"下方許多方法都接受一個 *index* 引數,用於選擇輸入框字串中的一個字元。如 Tk " +"``entry`` manual page 所述,*index* 可以是一個數字(從 0 開始計數)、" +"``'insert'``\\ (插入游標之後的字元)、``'end'``\\ (最後一個字元之後)、" +"``'anchor'``\\ (選取錨點)、``'sel.first'`` 和 ``'sel.last'``\\ (選取範圍的" +"兩端),或 ``@x``\\ (覆蓋視窗中像素 x 座標 *x* 的字元)。超出範圍的索引會被" +"四捨五入到最接近的合法值。" #: ../../library/tkinter.rst:4113 msgid "" @@ -5586,24 +6546,26 @@ msgid "" "*last*. If *last* is omitted, only the single character at *first* is " "deleted." msgstr "" +"刪除從索引 *first* 開始、到但不包含索引 *last* 為止的字元。若省略 *last*,則" +"只刪除 *first* 處的單一字元。" #: ../../library/tkinter.rst:4119 msgid "Return the entry's current string." -msgstr "" +msgstr "回傳輸入框目前的字串。" #: ../../library/tkinter.rst:4123 msgid "Insert *string* just before the character given by *index*." -msgstr "" +msgstr "在 *index* 所指定的字元之前插入 *string*。" #: ../../library/tkinter.rst:4127 ../../library/tkinter.rst:5044 msgid "" "Arrange for the insertion cursor to be displayed just before the character " "given by *index*." -msgstr "" +msgstr "安排將插入游標顯示在 *index* 所指定的字元之前。" #: ../../library/tkinter.rst:4132 msgid "Return the numerical index corresponding to *index*." -msgstr "" +msgstr "回傳對應於 *index* 的數字索引。" #: ../../library/tkinter.rst:4139 msgid "" @@ -5614,6 +6576,10 @@ msgid "" "*index* and the most recent anchor point, inclusive. :meth:`select_adjust` " "is an alias of :meth:`!selection_adjust`." msgstr "" +"找出最接近 *index* 所指定字元的選取範圍端點,並將該端點調整到 *index* (包含" +"但不超過它);另一端則成為未來 :meth:`selection_to` 呼叫的錨點。若輸入框中沒" +"有選取範圍,則會在 *index* 與最近一次的錨點之間(含兩端)建立一個新的選取範" +"圍。:meth:`select_adjust` 是 :meth:`!selection_adjust` 的別名。" #: ../../library/tkinter.rst:4152 msgid "" @@ -5621,12 +6587,16 @@ msgid "" "not in this widget the method has no effect. :meth:`select_clear` is an " "alias of :meth:`!selection_clear`." msgstr "" +"若選取範圍目前在此元件中,則清除該選取範圍。若選取範圍不在此元件中,則此方法" +"沒有作用。:meth:`select_clear` 是 :meth:`!selection_clear` 的別名。" #: ../../library/tkinter.rst:4158 msgid "" "This shadows the inherited :meth:`Misc.selection_clear`, which clears the X " "selection; that method is not available on an :class:`Entry`." msgstr "" +"這會遮蔽繼承的 :meth:`Misc.selection_clear`\\ (用於清除 X selection);此方" +"法在 :class:`Entry` 上不可用。" #: ../../library/tkinter.rst:4167 msgid "" @@ -5634,12 +6604,16 @@ msgid "" "*index*, without changing the selection. :meth:`select_from` is an alias of :" "meth:`!selection_from`." msgstr "" +"將選取錨點設定到 *index* 所指定字元之前,而不改變選取範圍。:meth:" +"`select_from` 是 :meth:`!selection_from` 的別名。" #: ../../library/tkinter.rst:4176 msgid "" "Return ``True`` if there are characters selected in the entry, ``False`` " "otherwise. :meth:`select_present` is an alias of :meth:`!selection_present`." msgstr "" +"若輸入框中有選取的字元則回傳 ``True``,否則回傳 ``False``。:meth:" +"`select_present` 是 :meth:`!selection_present` 的別名。" #: ../../library/tkinter.rst:4185 msgid "" @@ -5648,6 +6622,9 @@ msgid "" "same character as *start* or an earlier one, the selection is cleared. :meth:" "`select_range` is an alias of :meth:`!selection_range`." msgstr "" +"將選取範圍設定為包含從索引 *start* 開始、到 *end* 之前為止的字元。若 *end* 所" +"指的字元與 *start* 相同或在其之前,則會清除選取範圍。:meth:`select_range` " +"是 :meth:`!selection_range` 的別名。" #: ../../library/tkinter.rst:4196 msgid "" @@ -5659,6 +6636,12 @@ msgid "" "If there is no selection in the entry, a new one is created using the most " "recent anchor point. :meth:`select_to` is an alias of :meth:`!selection_to`." msgstr "" +"在錨點與 *index* 之間設定選取範圍:若 *index* 在錨點之前,則選取範圍從 " +"*index* 開始、到但不包含錨點為止;若 *index* 在錨點之後,則從錨點開始、到但不" +"包含 *index* 為止;若兩者重合,則不做任何事。錨點是由最近一次 :meth:" +"`selection_from` 或 :meth:`selection_adjust` 呼叫所設定的錨點。若輸入框中沒有" +"選取範圍,則會使用最近一次的錨點建立一個新的選取範圍。:meth:`select_to` 是 :" +"meth:`!selection_to` 的別名。" #: ../../library/tkinter.rst:4208 msgid "" @@ -5666,6 +6649,8 @@ msgid "" "meth:`scan_dragto` calls. Typically associated with a mouse button press in " "the widget." msgstr "" +"記錄 *x* 和輸入框視窗中目前的檢視,供之後的 :meth:`scan_dragto` 呼叫使用。通" +"常會與元件中的滑鼠按鍵按下事件相關聯。" #: ../../library/tkinter.rst:4214 msgid "" @@ -5674,6 +6659,9 @@ msgid "" "difference. Typically associated with mouse motion events, to produce the " "effect of dragging the entry at high speed through the window." msgstr "" +"計算 *x* 與上一次 :meth:`scan_mark` 呼叫所傳入 *x* 之間的差值,並將檢視向左或" +"向右調整該差值的 10 倍。通常會與滑鼠移動事件相關聯,以產生在視窗中高速拖曳輸" +"入框的效果。" #: ../../library/tkinter.rst:4223 msgid "" @@ -5683,6 +6671,10 @@ msgid "" "raised or sunken. Inherits from :class:`Widget`. Refer to the Tk ``frame`` " "manual page for the full list of options." msgstr "" +":class:`!Frame`\\ (框架)元件是一個簡單的容器。它的主要用途是作為間隔物,或" +"作為複雜視窗版面配置的容器;它唯一的特色是其背景,以及可讓框架呈現凸起或凹陷" +"外觀的選擇性 3D 邊框。繼承自 :class:`Widget`。有關選項的完整清單,請參閱 Tk " +"``frame`` manual page。" #: ../../library/tkinter.rst:4233 msgid "" @@ -5694,6 +6686,11 @@ msgid "" "class:`Widget`. Refer to the Tk ``label`` manual page for the full list of " "options." msgstr "" +":class:`!Label`\\ (標籤)元件會顯示不可互動的文字字串、點陣圖或圖片。顯示的" +"文字透過 *text* 選項設定,或透過 *textvariable* 連結到一個變數,圖片則可以使" +"用 *image* 選項顯示。文字都必須使用同一種字型,但可以佔用多行,並且可以使用 " +"*underline* 選項為一個字元加上底線。繼承自 :class:`Widget`。有關選項的完整清" +"單,請參閱 Tk ``label`` manual page。" #: ../../library/tkinter.rst:4245 msgid "" @@ -5704,6 +6701,10 @@ msgid "" "Inherits from :class:`Widget`. Refer to the Tk ``labelframe`` manual page " "for the full list of options." msgstr "" +":class:`!LabelFrame`\\ (標籤框架)元件是一個容器,具有 :class:`Frame` 的特" +"色,並能額外顯示一個標籤。標籤文字透過 *text* 選項設定,並透過 *labelanchor* " +"定位;也可以將任意元件作為 *labelwidget* 選項的值,用作標籤。繼承自 :class:" +"`Widget`。有關選項的完整清單,請參閱 Tk ``labelframe`` manual page。" #: ../../library/tkinter.rst:4256 msgid "" @@ -5718,6 +6719,14 @@ msgid "" "and vertically with :meth:`~XView.xview` and :meth:`~YView.yview`. Refer to " "the Tk ``listbox`` manual page for the full list of options." msgstr "" +":class:`!Listbox`\\ (清單方塊)元件會顯示一份單行文字項目的清單,每行一個項" +"目,使用者可以選取其中一個或多個項目。選取的行為由 *selectmode* 選項決定,其" +"值為 ``browse``\\ (預設值;最多一個項目,可用滑鼠拖曳)、``single``\\ (最多" +"一個項目)、``multiple``\\ (任意數量的項目,個別切換)或 ``extended``\\ (任" +"意數量的項目,包括不連續的範圍,透過點擊與拖曳選取)之一。繼承自 :class:" +"`Widget`、:class:`XView` 和 :class:`YView`,因此可以使用 :meth:`~XView." +"xview` 和 :meth:`~YView.yview` 水平與垂直捲動檢視。有關選項的完整清單,請參" +"閱 Tk ``listbox`` manual page。" #: ../../library/tkinter.rst:4268 msgid "" @@ -5730,6 +6739,13 @@ msgid "" "item covering pixel coordinates *x*, *y* in the listbox window). Arguments " "named *first* and *last* are indices of the same forms." msgstr "" +"許多方法都接受一個 *index* 引數,用於識別特定的項目。如 Tk ``listbox`` " +"manual page 所述,*index* 可以是一個數字索引(從頂部的 0 開始計數)、" +"``'active'``\\ (帶有定位游標的項目,由 :meth:`activate` 設定)、" +"``'anchor'``\\ (選取錨點,由 :meth:`selection_anchor` 設定)、``'end'``\\ " +"(最後一個項目,或對 :meth:`index` 和 :meth:`insert` 而言是緊接在其後的位" +"置),或 ``@x,y``\\ (清單方塊視窗中覆蓋像素座標 *x*、*y* 的項目)。名為 " +"*first* 和 *last* 的引數也是相同形式的索引。" #: ../../library/tkinter.rst:4279 msgid "" @@ -5737,12 +6753,16 @@ msgid "" "*index*. If *index* is ``'end'``, the new items are appended to the end of " "the list." msgstr "" +"將給定的 *elements* 作為新項目,插入到 *index* 所指定項目之前。若 *index* 為 " +"``'end'``,則新項目會附加到清單的末尾。" #: ../../library/tkinter.rst:4286 msgid "" "Delete the items in the range from *first* to *last* inclusive. If *last* is " "omitted, it defaults to *first*, so that a single item is deleted." msgstr "" +"刪除從 *first* 到 *last* (含兩端)範圍內的項目。若省略 *last*,則預設為 " +"*first*,因此只會刪除單一項目。" #: ../../library/tkinter.rst:4292 msgid "" @@ -5751,16 +6771,21 @@ msgid "" "given, return a tuple of all the items in the range from *first* to *last* " "inclusive." msgstr "" +"若省略 *last*,則回傳 *first* 所指定項目的內容,若 *first* 所指的項目不存在則" +"回傳空字串。若有給定 *last*,則回傳一個包含從 *first* 到 *last* (含兩端)範" +"圍內所有項目的元組。" #: ../../library/tkinter.rst:4299 msgid "Return the total number of items in the listbox." -msgstr "" +msgstr "回傳清單方塊中項目的總數。" #: ../../library/tkinter.rst:4301 msgid "" "This shadows the inherited :meth:`!Misc.size`; use :meth:`~Misc.grid_size` " "for the grid size." msgstr "" +"這會遮蔽繼承的 :meth:`!Misc.size`;請使用 :meth:`~Misc.grid_size` 取得網格大" +"小。" #: ../../library/tkinter.rst:4306 msgid "" @@ -5768,6 +6793,9 @@ msgid "" "*index* is out of range. If *index* is ``'end'``, the result is a count of " "the number of items in the listbox (not the index of the last item)." msgstr "" +"回傳對應於 *index* 的整數索引值,若 *index* 超出範圍則回傳 ``None``。若 " +"*index* 為 ``'end'``,則結果為清單方塊中項目的數量(而非最後一個項目的索" +"引)。" #: ../../library/tkinter.rst:4313 msgid "" @@ -5778,12 +6806,16 @@ msgid "" "the result still gives the full area of the item, including the parts that " "are not visible." msgstr "" +"回傳一個元組 ``(x, y, width, height)``,以相對於元件的像素描述 *index* 所指定" +"項目的文字外框。若該項目沒有任何部分在螢幕上可見,或 *index* 所指的項目不存" +"在,則回傳 ``None``;若該項目只有部分可見,結果仍會給出該項目的完整區域,包括" +"不可見的部分。" #: ../../library/tkinter.rst:4325 msgid "" "Given a y-coordinate within the listbox window, return the index of the " "visible item nearest to that y-coordinate." -msgstr "" +msgstr "給定清單方塊視窗中的一個 y 座標,回傳最接近該 y 座標的可見項目索引。" #: ../../library/tkinter.rst:4330 msgid "" @@ -5792,6 +6824,9 @@ msgid "" "window the listbox scrolls just enough to bring it into view at that edge, " "otherwise the listbox scrolls to center the item." msgstr "" +"調整檢視,使 *index* 所指定的項目可見。若該項目已經可見,則此方法沒有作用;若" +"該項目靠近視窗邊緣,清單方塊只會捲動剛好足夠的距離,使其在該邊緣可見,否則清" +"單方塊會捲動以將該項目置中。" #: ../../library/tkinter.rst:4337 msgid "" @@ -5800,12 +6835,16 @@ msgid "" "drawn as specified by the *activestyle* option when the widget has the input " "focus, and its index may be retrieved with the ``'active'`` index." msgstr "" +"將作用中項目設定為 *index* 所指定的項目。若 *index* 超出項目範圍,則改為啟用" +"最接近的項目。當元件擁有輸入焦點時,作用中項目會依 *activestyle* 選項所指定的" +"方式繪製,其索引可透過 ``'active'`` 索引取得。" #: ../../library/tkinter.rst:4346 msgid "" "Return a tuple containing the numerical indices of all of the items that are " "currently selected, or an empty tuple if no items are selected." msgstr "" +"回傳一個包含目前所有已選取項目數字索引的元組,若沒有項目被選取則回傳空元組。" #: ../../library/tkinter.rst:4354 msgid "" @@ -5815,6 +6854,10 @@ msgid "" "mouse, and may afterwards be referred to with the ``'anchor'`` index. :meth:" "`select_anchor` is an alias of :meth:`!selection_anchor`." msgstr "" +"將選取錨點設定為 *index* 所指定的項目。若 *index* 所指的項目不存在,則使用最" +"接近的項目。選取錨點是使用滑鼠拖曳選取範圍時保持固定的一端,之後可透過 " +"``'anchor'`` 索引參照它。:meth:`select_anchor` 是 :meth:`!selection_anchor` " +"的別名。" #: ../../library/tkinter.rst:4366 msgid "" @@ -5822,12 +6865,16 @@ msgid "" "are selected. The selection state of items outside this range is not " "changed. :meth:`select_clear` is an alias of :meth:`!selection_clear`." msgstr "" +"取消選取從 *first* 到 *last* (含兩端)範圍內任何已選取的項目。此範圍之外項目" +"的選取狀態不會改變。:meth:`select_clear` 是 :meth:`!selection_clear` 的別名。" #: ../../library/tkinter.rst:4373 msgid "" "This shadows the inherited :meth:`Misc.selection_clear`, which clears the X " "selection; that method is not available on a :class:`Listbox`." msgstr "" +"這會遮蔽繼承的 :meth:`Misc.selection_clear`\\ (用於清除 X selection);此方" +"法在 :class:`Listbox` 上不可用。" #: ../../library/tkinter.rst:4382 msgid "" @@ -5835,6 +6882,8 @@ msgid "" "``False`` otherwise. :meth:`select_includes` is an alias of :meth:`!" "selection_includes`." msgstr "" +"若 *index* 所指定的項目目前已被選取則回傳 ``True``,否則回傳 ``False``。:" +"meth:`select_includes` 是 :meth:`!selection_includes` 的別名。" #: ../../library/tkinter.rst:4391 msgid "" @@ -5842,12 +6891,14 @@ msgid "" "without affecting the selection state of items outside that range. :meth:" "`select_set` is an alias of :meth:`!selection_set`." msgstr "" +"選取從 *first* 到 *last* (含兩端)範圍內的所有項目,而不影響該範圍之外項目的" +"選取狀態。:meth:`select_set` 是 :meth:`!selection_set` 的別名。" #: ../../library/tkinter.rst:4397 msgid "" "Return the current value of the configuration option *option* for the item " "given by *index*." -msgstr "" +msgstr "回傳 *index* 所指定項目的設定選項 *option* 的目前值。" #: ../../library/tkinter.rst:4405 msgid "" @@ -5859,6 +6910,11 @@ msgid "" "*selectbackground* and *selectforeground*. :meth:`itemconfig` is an alias " "of :meth:`!itemconfigure`." msgstr "" +"查詢或修改 *index* 所指定項目的設定選項。這與 :meth:`~Misc.configure` 類似," +"差別在於它套用於個別項目,而非整個清單方塊。若沒有給定選項,則回傳一個描述該" +"項目目前選項的字典;否則會設定給定的選項。支援的項目選項有 *background*、" +"*foreground*、*selectbackground* 和 *selectforeground*。:meth:`itemconfig` " +"是 :meth:`!itemconfigure` 的別名。" #: ../../library/tkinter.rst:4422 msgid "" @@ -5867,6 +6923,9 @@ msgid "" "bound to mouse motion events in the widget, producing the effect of dragging " "the list at high speed through the window." msgstr "" +"將清單方塊捲動 10 倍於 *x*、*y* 與上一次 :meth:`scan_mark` 呼叫所傳入座標之間" +"的差值。這通常會綁定到元件中的滑鼠移動事件,產生以高速在視窗中拖曳清單的效" +"果。" #: ../../library/tkinter.rst:4430 msgid "" @@ -5876,6 +6935,10 @@ msgid "" "as pulldown menus posted from a cascade entry or menubutton, and as popup " "menus. Inherits from :class:`Widget`." msgstr "" +":class:`!Menu`\\ (選單)元件會顯示一欄項目,每個項目可以是一個命令、核取按" +"鈕、單選按鈕、階層(會顯示相關聯的子選單)或分隔線。選單可用作頂層視窗的選單" +"列、由階層項目或選單按鈕顯示的下拉選單,以及彈出選單。繼承自 :class:" +"`Widget`。" #: ../../library/tkinter.rst:4437 msgid "" @@ -5887,6 +6950,12 @@ msgid "" "coordinate *y* in the menu window), or a pattern matched against the labels " "of the entries from the top down." msgstr "" +"許多項目方法都接受一個 *index* 引數,用於選擇要操作的項目。如 Tk ``menu`` " +"manual page 所述,*index* 可以是一個數字索引(從頂部的 0 開始計數)、" +"``'active'``\\ (目前作用中的項目)、``'end'`` 或 ``'last'``\\ (最底部的項" +"目)、``'none'``\\ (完全沒有項目,在 Tcl 中寫作 ``{}``)、``@y``\\ (選單視" +"窗中覆蓋像素 y 座標 *y* 的項目),或是一個從頂部往下與項目標籤進行比對的樣" +"式。" #: ../../library/tkinter.rst:4448 msgid "" @@ -5897,20 +6966,27 @@ msgid "" "`!add_checkbutton`, :meth:`!add_radiobutton` and :meth:`!add_separator` " "convenience methods call this method with the corresponding *itemType*." msgstr "" +"在選單底部新增一個項目。*itemType* 為 ``'command'``、``'cascade'``、" +"``'checkbutton'``、``'radiobutton'`` 或 ``'separator'`` 之一,用於決定新項目" +"的類型;其餘的選項則用於設定該項目。:meth:`!add_command`、:meth:`!" +"add_cascade`、:meth:`!add_checkbutton`、:meth:`!add_radiobutton` 和 :meth:`!" +"add_separator` 這些便利方法會以對應的 *itemType* 呼叫此方法。" #: ../../library/tkinter.rst:4456 msgid "" "The entry is configured by the following options, although not every option " "applies to every entry type (a separator accepts none of them):" msgstr "" +"項目由以下選項設定,不過並非每個選項都適用於每種項目類型(分隔線不接受其中任" +"何一個):" #: ../../library/tkinter.rst:4459 msgid "*label*" -msgstr "" +msgstr "*label*" #: ../../library/tkinter.rst:4460 msgid "The text to display in the entry." -msgstr "" +msgstr "要在該項目中顯示的文字。" #: ../../library/tkinter.rst:4462 msgid "*command*" @@ -5920,146 +6996,149 @@ msgstr "*command*" msgid "" "The function to call when the entry is invoked (command, checkbutton and " "radiobutton entries)." -msgstr "" +msgstr "當項目被觸發時要呼叫的函式(命令、核取按鈕和單選按鈕項目)。" #: ../../library/tkinter.rst:4466 msgid "*accelerator*" -msgstr "" +msgstr "*accelerator*" #: ../../library/tkinter.rst:4467 msgid "" "A string displayed at the right of the entry to advertise an accelerator " "keystroke; it does not itself create the binding." msgstr "" +"顯示在項目右側、用於提示快速鍵按鍵組合的字串;它本身並不會建立該按鍵綁定。" #: ../../library/tkinter.rst:4471 msgid "" "The index of a character in the label to underline for keyboard traversal." -msgstr "" +msgstr "標籤中要加上底線以供鍵盤走訪的字元索引。" #: ../../library/tkinter.rst:4475 msgid "One of ``'normal'``, ``'active'`` or ``'disabled'``." -msgstr "" +msgstr "``'normal'``、``'active'`` 或 ``'disabled'`` 之一。" #: ../../library/tkinter.rst:4478 msgid "An image to display instead of, or together with, the text label." -msgstr "" +msgstr "要顯示以取代文字標籤,或與文字標籤一起顯示的圖片。" #: ../../library/tkinter.rst:4480 msgid "*compound*" -msgstr "" +msgstr "*compound*" #: ../../library/tkinter.rst:4481 msgid "" "Where to show the image relative to the text: ``'none'`` (the default), " "``'text'``, ``'image'``, ``'top'``, ``'bottom'``, ``'left'`` or ``'right'``." msgstr "" +"圖片相對於文字要顯示的位置:``'none'``\\ (預設值)、``'text'``、" +"``'image'``、``'top'``、``'bottom'``、``'left'`` 或 ``'right'``。" #: ../../library/tkinter.rst:4486 msgid "A bitmap to display instead of the text label." -msgstr "" +msgstr "要顯示以取代文字標籤的點陣圖。" #: ../../library/tkinter.rst:4489 ../../library/tkinter.rst:5373 msgid "The font to use for the text." -msgstr "" +msgstr "要用於文字的字型。" #: ../../library/tkinter.rst:4492 msgid "" "The entry's background and foreground colors in its normal state (ignored on " "macOS)." -msgstr "" +msgstr "項目在一般狀態下的背景色和前景色(在 macOS 上會被忽略)。" #: ../../library/tkinter.rst:4495 msgid "*activebackground*, *activeforeground*" -msgstr "" +msgstr "*activebackground*, *activeforeground*" #: ../../library/tkinter.rst:4496 msgid "" "The background and foreground colors used when the entry is active (ignored " "on macOS)." -msgstr "" +msgstr "項目處於作用中狀態時所使用的背景色和前景色(在 macOS 上會被忽略)。" #: ../../library/tkinter.rst:4499 msgid "*columnbreak*" -msgstr "" +msgstr "*columnbreak*" #: ../../library/tkinter.rst:4500 msgid "" "If true, the entry starts a new column instead of being placed below the " "previous entry." -msgstr "" +msgstr "若為真,該項目會另起一欄,而不是被放置在前一個項目下方。" #: ../../library/tkinter.rst:4503 msgid "*hidemargin*" -msgstr "" +msgstr "*hidemargin*" #: ../../library/tkinter.rst:4504 msgid "" "If true, the standard margin around the entry is omitted, which is useful " "when a menu is used as a palette." -msgstr "" +msgstr "若為真,則會省略項目周圍的標準邊界,這在選單用作調色盤時很有用。" #: ../../library/tkinter.rst:4507 msgid "*menu*" -msgstr "" +msgstr "*menu*" #: ../../library/tkinter.rst:4508 msgid "The submenu posted by a cascade entry; it must be a child of this menu." -msgstr "" +msgstr "由階層項目所顯示的子選單;它必須是此選單的子項。" #: ../../library/tkinter.rst:4511 msgid "*variable*" -msgstr "" +msgstr "*variable*" #: ../../library/tkinter.rst:4512 msgid "The variable associated with a checkbutton or radiobutton entry." -msgstr "" +msgstr "與核取按鈕或單選按鈕項目相關聯的變數。" #: ../../library/tkinter.rst:4514 msgid "*onvalue*, *offvalue*" -msgstr "" +msgstr "*onvalue*, *offvalue*" #: ../../library/tkinter.rst:4515 msgid "" "The values stored in *variable* when a checkbutton entry is selected or " "cleared." -msgstr "" +msgstr "核取按鈕項目被選取或清除時,儲存在 *variable* 中的值。" #: ../../library/tkinter.rst:4518 msgid "*value*" -msgstr "" +msgstr "*value*" #: ../../library/tkinter.rst:4519 msgid "The value stored in *variable* when a radiobutton entry is selected." -msgstr "" +msgstr "單選按鈕項目被選取時,儲存在 *variable* 中的值。" #: ../../library/tkinter.rst:4521 msgid "*indicatoron*" -msgstr "" +msgstr "*indicatoron*" #: ../../library/tkinter.rst:4522 msgid "Whether to display the indicator of a checkbutton or radiobutton entry." -msgstr "" +msgstr "是否顯示核取按鈕或單選按鈕項目的指示器。" #: ../../library/tkinter.rst:4525 msgid "*selectcolor*" -msgstr "" +msgstr "*selectcolor*" #: ../../library/tkinter.rst:4526 msgid "" "The color of the indicator of a checkbutton or radiobutton entry when it is " "selected." -msgstr "" +msgstr "核取按鈕或單選按鈕項目被選取時,其指示器的顏色。" #: ../../library/tkinter.rst:4529 msgid "*selectimage*" -msgstr "" +msgstr "*selectimage*" #: ../../library/tkinter.rst:4530 msgid "" "The image displayed when a checkbutton or radiobutton entry is selected and " "*image* is also given." -msgstr "" +msgstr "當核取按鈕或單選按鈕項目被選取,且也有給定 *image* 時所顯示的圖片。" #: ../../library/tkinter.rst:4535 msgid "" @@ -6067,6 +7146,8 @@ msgid "" "associated submenu, given by its *menu* option, which must be a child of " "this menu; posting the entry posts the submenu next to it." msgstr "" +"在選單底部新增一個階層項目。階層項目具有一個由其 *menu* 選項所指定的相關聯子" +"選單,該子選單必須是此選單的子項;顯示該項目時會在其旁邊顯示子選單。" #: ../../library/tkinter.rst:4542 msgid "" @@ -6075,6 +7156,9 @@ msgid "" "result in its associated *variable*, and displays an indicator showing " "whether it is selected." msgstr "" +"在選單底部新增一個核取按鈕項目。核取按鈕項目被觸發時,會在其 *onvalue* 和 " +"*offvalue* 之間切換,將結果儲存在其相關聯的 *variable* 中,並顯示一個指示器來" +"表示它是否被選取。" #: ../../library/tkinter.rst:4549 msgid "" @@ -6082,6 +7166,8 @@ msgid "" "much like a button: when it is invoked, the callback given by its *command* " "option is called." msgstr "" +"在選單底部新增一個命令項目。命令項目的行為很像按鈕:當它被觸發時,會呼叫其 " +"*command* 選項所指定的回呼函式。" #: ../../library/tkinter.rst:4555 msgid "" @@ -6089,12 +7175,16 @@ msgid "" "sharing the same *variable* form a group of which only one may be selected " "at a time; selecting an entry stores its *value* in the variable." msgstr "" +"在選單底部新增一個單選按鈕項目。共用相同 *variable* 的單選按鈕項目會形成一個" +"群組,該群組中一次只能選取一個項目;選取某個項目會將其 *value* 儲存到該變數" +"中。" #: ../../library/tkinter.rst:4562 msgid "" "Add a separator to the bottom of the menu. A separator is displayed as a " "horizontal dividing line and cannot be activated or invoked." msgstr "" +"在選單底部新增一條分隔線。分隔線會顯示為一條水平分隔線,且無法被啟用或觸發。" #: ../../library/tkinter.rst:4568 msgid "" @@ -6106,36 +7196,49 @@ msgid "" "and :meth:`!insert_separator` convenience methods call this method with the " "corresponding *itemType*." msgstr "" +"與 :meth:`add` 相同,差別在於新項目會被插入到 *index* 所指定項目之前,而不是" +"附加到選單的末尾。*itemType* 為 ``'command'``、``'cascade'``、" +"``'checkbutton'``、``'radiobutton'`` 或 ``'separator'`` 之一。:meth:`!" +"insert_command`、:meth:`!insert_cascade`、:meth:`!insert_checkbutton`、:meth:" +"`!insert_radiobutton` 和 :meth:`!insert_separator` 這些便利方法會以對應的 " +"*itemType* 呼叫此方法。" #: ../../library/tkinter.rst:4580 msgid "" "Insert a new cascade entry before the entry given by *index* (see :meth:" "`add_cascade`)." msgstr "" +"在 *index* 所指定的項目之前插入一個新的階層項目(見 :meth:`add_cascade`)。" #: ../../library/tkinter.rst:4585 msgid "" "Insert a new checkbutton entry before the entry given by *index* (see :meth:" "`add_checkbutton`)." msgstr "" +"在 *index* 所指定的項目之前插入一個新的核取按鈕項目(見 :meth:" +"`add_checkbutton`)。" #: ../../library/tkinter.rst:4590 msgid "" "Insert a new command entry before the entry given by *index* (see :meth:" "`add_command`)." msgstr "" +"在 *index* 所指定的項目之前插入一個新的命令項目(見 :meth:`add_command`)。" #: ../../library/tkinter.rst:4595 msgid "" "Insert a new radiobutton entry before the entry given by *index* (see :meth:" "`add_radiobutton`)." msgstr "" +"在 *index* 所指定的項目之前插入一個新的單選按鈕項目(見 :meth:" +"`add_radiobutton`)。" #: ../../library/tkinter.rst:4600 msgid "" "Insert a separator before the entry given by *index* (see :meth:" "`add_separator`)." msgstr "" +"在 *index* 所指定的項目之前插入一條分隔線(見 :meth:`add_separator`)。" #: ../../library/tkinter.rst:4605 msgid "" @@ -6144,12 +7247,15 @@ msgid "" "deleted. Attempts to delete a tear-off entry are ignored; remove it by " "changing the *tearoff* option instead." msgstr "" +"刪除 *index1* 到 *index2* (含兩端)之間的所有選單項目。若省略 *index2*,則預" +"設為 *index1*,因此只會刪除單一項目。嘗試刪除撕下項目的動作會被忽略;請改為變" +"更 *tearoff* 選項來移除它。" #: ../../library/tkinter.rst:4613 msgid "" "Return the current value of the configuration option *option* for the entry " "given by *index*." -msgstr "" +msgstr "回傳 *index* 所指定項目的設定選項 *option* 的目前值。" #: ../../library/tkinter.rst:4621 msgid "" @@ -6161,12 +7267,17 @@ msgid "" "`add` for the entry's type. :meth:`entryconfig` is an alias of :meth:`!" "entryconfigure`." msgstr "" +"查詢或修改 *index* 所指定項目的設定選項。這與 :meth:`~Misc.configure` 類似," +"差別在於它套用於個別項目,而非整個選單。若沒有給定選項,則回傳一個描述該項目" +"目前選項的字典;否則會設定給定的選項。支援的選項為 :meth:`add` 針對該項目類型" +"所接受的選項。:meth:`entryconfig` 是 :meth:`!entryconfigure` 的別名。" #: ../../library/tkinter.rst:4632 msgid "" "Return the numerical index corresponding to *index*, or ``None`` if *index* " "selects no entry." msgstr "" +"回傳對應於 *index* 的數字索引,若 *index* 沒有選取任何項目則回傳 ``None``。" #: ../../library/tkinter.rst:4637 msgid "" @@ -6174,6 +7285,9 @@ msgid "" "``'cascade'``, ``'checkbutton'``, ``'radiobutton'``, ``'separator'`` or " "``'tearoff'`` (for the tear-off entry)." msgstr "" +"回傳 *index* 所指定項目的類型:``'command'``、``'cascade'``、" +"``'checkbutton'``、``'radiobutton'``、``'separator'`` 或 ``'tearoff'``\\ (用" +"於撕下項目)之一。" #: ../../library/tkinter.rst:4643 msgid "" @@ -6182,6 +7296,9 @@ msgid "" "selects no entry, or the selected entry is disabled, the menu ends up with " "no active entry." msgstr "" +"將 *index* 所指定的項目設為作用中項目,以其作用中顏色重新顯示,並停用任何先前" +"的作用中項目。若 *index* 沒有選取任何項目,或所選取的項目已被停用,則選單最終" +"不會有任何作用中項目。" #: ../../library/tkinter.rst:4650 msgid "" @@ -6190,6 +7307,8 @@ msgid "" "associated with it, the result of that command is returned; otherwise the " "result is an empty string." msgstr "" +"觸發 *index* 所指定項目的動作,如同它被點擊一樣。若該項目已被停用,則不會有任" +"何動作。若該項目有相關聯的 *command*,則回傳該命令的結果;否則回傳空字串。" #: ../../library/tkinter.rst:4658 msgid "" @@ -6198,6 +7317,8 @@ msgid "" "*postcommand* option has been specified, it is evaluated before the menu is " "posted." msgstr "" +"在螢幕上根視窗座標 *x* 和 *y* 處顯示選單,並在必要時調整座標,使整個選單可" +"見。若有指定 *postcommand* 選項,則會在顯示選單之前執行它。" #: ../../library/tkinter.rst:4665 msgid "" @@ -6205,6 +7326,8 @@ msgid "" "*entry* is given, the menu is positioned so that this entry is displayed " "under the pointer." msgstr "" +"在根視窗座標 *x* 和 *y* 處以彈出選單的方式顯示此選單。若有給定 *entry*,則會" +"調整選單的位置,使該項目顯示在指標下方。" #: ../../library/tkinter.rst:4671 msgid "" @@ -6212,18 +7335,20 @@ msgid "" "lower-level cascaded submenu. This has no effect on Windows and macOS, which " "manage the unposting of menus themselves." msgstr "" +"取消映射此選單,使其不再顯示,同時也會取消顯示任何已顯示的下層階層子選單。這" +"在 Windows 和 macOS 上沒有作用,因為它們會自行管理選單的取消顯示。" #: ../../library/tkinter.rst:4678 msgid "" "Return the x-coordinate, within the menu window, of the leftmost pixel of " "the entry given by *index*." -msgstr "" +msgstr "回傳 *index* 所指定項目最左側像素在選單視窗中的 x 座標。" #: ../../library/tkinter.rst:4685 msgid "" "Return the y-coordinate, within the menu window, of the topmost pixel of the " "entry given by *index*." -msgstr "" +msgstr "回傳 *index* 所指定項目最頂端像素在選單視窗中的 y 座標。" #: ../../library/tkinter.rst:4691 msgid "" @@ -6234,6 +7359,11 @@ msgid "" "relative to the button. Inherits from :class:`Widget`. Refer to the Tk " "``menubutton`` manual page for the full list of options." msgstr "" +":class:`!Menubutton`\\ (選單按鈕)元件會顯示一個文字字串、點陣圖或圖片,並在" +"使用者按下時顯示其 *menu* 選項所指定的相關聯 :class:`Menu`。如同 :class:" +"`Label` 一樣,它可以顯示 *text*、*textvariable* 或 *image*,而 *direction* 選" +"項則控制選單相對於按鈕出現的位置。繼承自 :class:`Widget`。有關選項的完整清" +"單,請參閱 Tk ``menubutton`` manual page。" #: ../../library/tkinter.rst:4703 msgid "" @@ -6245,6 +7375,11 @@ msgid "" "`Widget`. Refer to the Tk ``message`` manual page for the full list of " "options." msgstr "" +":class:`!Message`\\ (訊息)元件會顯示一個不可互動的文字字串,該字串由 " +"*text* 選項給定,或透過 *textvariable* 連結到一個變數。與 :class:`Label` 不同" +"的是,它會將字串拆成多行,以產生指定的長寬比,並在單字邊界處選擇換行位置,還" +"可以將文字靠左、置中或靠右對齊。繼承自 :class:`Widget`。有關選項的完整清單," +"請參閱 Tk ``message`` manual page。" #: ../../library/tkinter.rst:4714 msgid "" @@ -6255,14 +7390,18 @@ msgid "" "callback that is invoked with the selected value, and the keyword argument " "*name* sets the Tk widget name." msgstr "" +":class:`Menubutton` 的一個輔助子類別,會顯示一個包含互斥選項的彈出選單。" +"*variable* 是一個與選取內容保持同步的 :class:`Variable`,*value* 是初始選項," +"而 *values* 則是其餘的選單項目。關鍵字引數 *command* 可以指定一個會以選取的值" +"作為引數呼叫的回呼函式;關鍵字引數 *name* 則用於設定 Tk 元件名稱。" #: ../../library/tkinter.rst:4723 msgid "Destroy the widget, also cleaning up the associated pop-up menu." -msgstr "" +msgstr "銷毀該元件,同時清理相關聯的彈出選單。" #: ../../library/tkinter.rst:4725 msgid "Added support for the *name* keyword argument." -msgstr "" +msgstr "新增支援 *name* 關鍵字引數。" #: ../../library/tkinter.rst:4732 msgid "" @@ -6273,6 +7412,11 @@ msgid "" "can drag with the mouse to resize the widgets on either side of it. Inherits " "from :class:`Widget`." msgstr "" +":class:`!PanedWindow` 是一種佈局管理器元件,可將任意數量的子\\ *窗格*\\ 排列" +"成一列(當 *orient* 為 ``'horizontal'`` 時)或一欄(當 *orient* 為 " +"``'vertical'`` 時)。每個窗格容納一個元件,且每對相鄰窗格之間都由一條可移動的" +"\\ *分隔條*\\ 隔開,使用者可以用滑鼠拖曳它來調整兩側元件的大小。繼承自 :" +"class:`Widget`。" #: ../../library/tkinter.rst:4740 msgid "" @@ -6281,6 +7425,10 @@ msgid "" "handle is drawn on each sash that the user can grab to drag it. Refer to the " "Tk ``panedwindow`` manual page for the full list of options." msgstr "" +"*orient* 選項用於選擇佈局方向,*sashwidth* 設定每條分隔條的寬度," +"*sashrelief* 設定其浮雕樣式。當 *showhandle* 為真時,每條分隔條上會繪製一個小" +"把手,供使用者抓取以拖曳該分隔條。完整的選項清單請參閱 Tk 的 ``panedwindow`` " +"手冊頁。" #: ../../library/tkinter.rst:4748 msgid "" @@ -6288,6 +7436,9 @@ msgid "" "panes. The keyword arguments specify per-pane management options for " "*child*; they may be any of the options accepted by :meth:`paneconfigure`." msgstr "" +"將 *child* 加入此 PanedWindow 作為新的窗格,並放置在所有現有窗格之後。關鍵字" +"引數用於指定 *child* 的個別窗格管理選項,可以是 :meth:`paneconfigure` 所接受" +"的任何選項。" #: ../../library/tkinter.rst:4758 msgid "" @@ -6297,12 +7448,17 @@ msgid "" "use :meth:`~Pack.pack_forget`, :meth:`~Grid.grid_forget` or :meth:`~Place." "place_forget` to remove the widget itself from its manager." msgstr "" +"從此 PanedWindow 中移除包含 *child* 的窗格。*child* 的所有佈局管理選項都會被" +"遺忘。:meth:`forget` 是 :meth:`!remove` 的別名。這會遮蔽繼承而來的佈局管理器" +"方法 :meth:`!forget`;如要將元件本身從其管理器中移除,請使用 :meth:`~Pack." +"pack_forget`、:meth:`~Grid.grid_forget` 或 :meth:`~Place.place_forget`。" #: ../../library/tkinter.rst:4767 msgid "" "Return a tuple of the widgets managed by the panedwindow, one per pane, in " "order." msgstr "" +"回傳一個由此 PanedWindow 所管理之元件所組成的 tuple,依序每個窗格一個元件。" #: ../../library/tkinter.rst:4772 msgid "" @@ -6310,6 +7466,8 @@ msgid "" "containing *child*. *option* may be any value allowed by :meth:" "`paneconfigure`." msgstr "" +"回傳包含 *child* 的窗格中管理選項 *option* 的目前值。*option* 可以是 :meth:" +"`paneconfigure` 所允許的任何值。" #: ../../library/tkinter.rst:4781 msgid "" @@ -6328,6 +7486,16 @@ msgid "" "``'first'``, ``'last'``, ``'middle'`` or ``'never'``). :meth:`paneconfig` is " "an alias of :meth:`!paneconfigure`." msgstr "" +"查詢或修改包含元件 *tagOrId* 的窗格的管理選項。若未提供任何選項,會回傳一個描" +"述該窗格所有可用選項的 dictionary;若提供單一選項名稱字串,則回傳該選項的描" +"述;否則會設定所給定的選項。支援的選項包括 *after* 和 *before* (將窗格插入在" +"另一個受管理視窗之後或之前)、*height* 和 *width* (視窗的外部尺寸,包含任何" +"邊框)、*minsize* (在分隔方向上的最小尺寸)、*padx* 和 *pady* (在視窗每側保" +"留的額外空間)、*sticky* (在過大的窗格中定位或延展視窗,使用由 ``n``、" +"``s``、``e`` 和 ``w`` 等字元組成的字串)、*hide* (隱藏窗格但仍將其保留在窗格" +"清單中),以及 *stretch* (如何將額外空間分配給窗格:``'always'``、" +"``'first'``、``'last'``、``'middle'`` 或 ``'never'`` 其中之一)。:meth:" +"`paneconfig` 是 :meth:`!paneconfigure` 的別名。" #: ../../library/tkinter.rst:4799 msgid "" @@ -6338,6 +7506,11 @@ msgid "" "'sash')`` or ``(2, 'handle')``. If the point is over any other part of the " "panedwindow, the result is an empty string." msgstr "" +"辨識位於視窗座標中 *x* 和 *y* 所指定之點下方的 PanedWindow 元件部位。若該點位" +"於分隔條或分隔條把手之上,結果會是一個包含兩個元素的 tuple,其中包含該分隔條" +"或把手的索引,以及一個表示該處是分隔條還是把手的字詞,例如 ``(0, 'sash')`` " +"或 ``(2, 'handle')``。若該點位於此 PanedWindow 的其他部分之上,結果則為空字" +"串。" #: ../../library/tkinter.rst:4810 msgid "" @@ -6346,6 +7519,9 @@ msgid "" "meth:`sash_coord`, :meth:`sash_mark` and :meth:`sash_place` should normally " "be used instead." msgstr "" +"查詢或改變此 PanedWindow 中各分隔條的位置。這是 Tk ``sash`` 子指令的薄封裝;" +"一般情況下應改用便利方法 :meth:`sash_coord`、:meth:`sash_mark` 和 :meth:" +"`sash_place`。" #: ../../library/tkinter.rst:4817 msgid "" @@ -6354,16 +7530,21 @@ msgid "" "the panedwindow. The coordinates returned are those of the top left corner " "of the region containing the sash." msgstr "" +"回傳由 *index* 所指定之分隔條目前的 x、y 座標對,*index* 必須是介於 0 到此 " +"PanedWindow 窗格數量減一之間的整數。回傳的座標為包含該分隔條之區域的左上角座" +"標。" #: ../../library/tkinter.rst:4825 msgid "" "Record the current mouse position for the sash given by *index*, for use " "together with later sash-drag operations to move the sash." msgstr "" +"記錄由 *index* 所指定之分隔條目前的滑鼠位置,供之後的分隔條拖曳操作用來移動該" +"分隔條。" #: ../../library/tkinter.rst:4830 msgid "Place the sash given by *index* at the coordinates *x* and *y*." -msgstr "" +msgstr "將由 *index* 所指定的分隔條放置在座標 *x* 和 *y* 處。" #: ../../library/tkinter.rst:4834 msgid "" @@ -6373,20 +7554,24 @@ msgid "" "`proxy_coord`, :meth:`proxy_forget` and :meth:`proxy_place` should normally " "be used instead." msgstr "" +"查詢或改變分隔條代理(sash proxy)的位置,此代理是在以非不透明方式調整大小拖" +"曳分隔條時所顯示的「幽靈」分隔條。這是 Tk ``proxy`` 子指令的薄封裝;一般情況" +"下應改用便利方法 :meth:`proxy_coord`、:meth:`proxy_forget` 和 :meth:" +"`proxy_place`。" #: ../../library/tkinter.rst:4842 msgid "" "Return a tuple containing the x and y coordinates of the most recent proxy " "location." -msgstr "" +msgstr "回傳一個包含最近一次代理位置 x、y 座標的 tuple。" #: ../../library/tkinter.rst:4847 msgid "Remove the proxy from the display." -msgstr "" +msgstr "將代理從畫面上移除。" #: ../../library/tkinter.rst:4851 msgid "Place the proxy at the coordinates *x* and *y*." -msgstr "" +msgstr "將代理放置在座標 *x* 和 *y* 處。" #: ../../library/tkinter.rst:4856 msgid "" @@ -6401,6 +7586,13 @@ msgid "" "options documented in the Tk ``radiobutton`` manual page, such as " "*variable*, *value* and *command*." msgstr "" +":class:`!Radiobutton` 元件會顯示一段文字字串、點陣圖或圖片,並搭配一個菱形或" +"圓形指示器,用於在多個選項中選擇一個。它具有簡單按鈕的所有行為,此外還可以被" +"選取:通常會有數個 radiobutton 共用同一個 *variable*,選取其中一個會將該變數" +"設為該 radiobutton 的 *value*;每個 radiobutton 也會監控該變數,並在變數改變" +"時自動選取或取消選取自身。繼承自 :class:`Widget`。除了標準元件選項之外," +"radiobutton 還接受 Tk ``radiobutton`` 手冊頁中所記載的選項,例如 *variable*、" +"*value* 和 *command*。" #: ../../library/tkinter.rst:4871 msgid "" @@ -6410,18 +7602,23 @@ msgid "" "associated with the radiobutton. This is ignored if the radiobutton's state " "is ``disabled``." msgstr "" +"執行使用者以滑鼠按下該 radiobutton 時會發生的動作:選取該按鈕並叫用相關聯的命" +"令(若有的話)。回傳該命令的結果,若沒有與此 radiobutton 相關聯的命令則回傳空" +"字串。若此 radiobutton 的狀態為 ``disabled``,則此方法會被忽略。" #: ../../library/tkinter.rst:4880 msgid "" "Select the radiobutton and set the associated variable to the value " "corresponding to this widget." -msgstr "" +msgstr "選取此 radiobutton,並將相關聯的變數設為對應此元件的值。" #: ../../library/tkinter.rst:4885 msgid "" "Deselect the radiobutton and set the associated variable to an empty string. " "If this radiobutton was not currently selected, this has no effect." msgstr "" +"取消選取此 radiobutton,並將相關聯的變數設為空字串。若此 radiobutton 目前並未" +"被選取,則此方法沒有作用。" #: ../../library/tkinter.rst:4891 msgid "" @@ -6430,6 +7627,9 @@ msgid "" "left in the same normal or active state as when the method was called. This " "is ignored if the radiobutton's state is ``disabled``." msgstr "" +"讓此 radiobutton 閃爍,方式是重新顯示它數次,並在作用中與一般顏色之間交替。閃" +"爍結束後,此 radiobutton 會維持與呼叫此方法時相同的一般或作用中狀態。若此 " +"radiobutton 的狀態為 ``disabled``,則此方法會被忽略。" #: ../../library/tkinter.rst:4900 msgid "" @@ -6438,6 +7638,8 @@ msgid "" "optionally display a label and the current value. Inherits from :class:" "`Widget`." msgstr "" +":class:`!Scale` 元件讓使用者透過沿著溝槽移動滑桿來選擇一個數值。它可以垂直或" +"水平定向,並可選擇性地顯示標籤與目前的值。繼承自 :class:`Widget`。" #: ../../library/tkinter.rst:4906 msgid "" @@ -6448,24 +7650,34 @@ msgid "" "dropped; *from* is spelled ``from_`` because :keyword:`from` is a Python " "keyword." msgstr "" +"除了標準元件選項之外,scale 還接受 Tk ``scale`` 手冊頁中所記載的選項,例如 " +"*from_*、*to*、*resolution*、*orient*、*tickinterval*、*variable* 和 " +"*command*。與 :mod:`!tkinter` 中其他地方一樣,Tk 選項名稱開頭的 ``-`` 會被省" +"略;*from* 拼寫為 ``from_``,因為 :keyword:`from` 是 Python 的關鍵字。" #: ../../library/tkinter.rst:4913 msgid "" "With a non-integer *resolution*, see :ref:`numeric values and the locale " "`." msgstr "" +"若 *resolution* 為非整數,請參閱\\ :ref:`數值與地區設定 `。" #: ../../library/tkinter.rst:4918 msgid "" "Return the current value of the scale. The result is an integer if the " "scale's *resolution* yields whole numbers, and a float otherwise." msgstr "" +"回傳此 scale 目前的值。若 scale 的 *resolution* 產生整數,結果為 int;否則為 " +"float。" #: ../../library/tkinter.rst:4924 msgid "" "Set the scale to *value*, moving the slider accordingly. This has no effect " "if the scale is disabled." msgstr "" +"將 scale 設為 *value*,並相應地移動滑桿。若此 scale 已停用,則此方法沒有作" +"用。" #: ../../library/tkinter.rst:4929 msgid "" @@ -6473,6 +7685,8 @@ msgid "" "widget, of the point on the centerline of the trough that corresponds to " "*value*. If *value* is omitted, the scale's current value is used." msgstr "" +"回傳一個 tuple ``(x, y)``,表示對應 *value* 之溝槽中心線上該點相對於此元件的" +"像素座標。若省略 *value*,則使用 scale 目前的值。" #: ../../library/tkinter.rst:4936 msgid "" @@ -6481,6 +7695,9 @@ msgid "" "the left of the slider), ``'trough2'`` (below or to the right of the " "slider), or an empty string if the point is not over any of these elements." msgstr "" +"回傳一個描述位於像素座標 *x*、*y* 處之 scale 部位的字串:``'slider'``、" +"``'trough1'``\\ (滑桿上方或左側的溝槽部分)、``'trough2'``\\ (滑桿下方或右" +"側的溝槽部分),若該點不在這些元素之上,則回傳空字串。" #: ../../library/tkinter.rst:4945 msgid "" @@ -6492,6 +7709,12 @@ msgid "" "to the scrolled widget's :meth:`~XView.xview` or :meth:`~YView.yview` " "method. Inherits from :class:`Widget`." msgstr "" +":class:`!Scrollbar` 元件會顯示一個滑桿與兩個箭頭,讓使用者可以捲動相關聯的元" +"件,例如 :class:`Listbox`、:class:`Text`、:class:`Canvas` 或 :class:`Entry`。" +"將該元件的 *xscrollcommand* 或 *yscrollcommand* 選項設為此 scrollbar 的 :" +"meth:`set` 方法,並將此 scrollbar 的 *command* 選項設為被捲動元件的 :meth:" +"`~XView.xview` 或 :meth:`~YView.yview` 方法,即可將兩者連接起來。繼承自 :" +"class:`Widget`。" #: ../../library/tkinter.rst:4956 msgid "" @@ -6499,6 +7722,8 @@ msgid "" "fractions between 0 and 1, describing the portion of the document that is " "currently visible, as last passed to :meth:`set`." msgstr "" +"以 tuple ``(first, last)`` 的形式回傳目前的 scrollbar 設定,這兩個介於 0 到 " +"1 之間的分數描述了文件中目前可見的部分,即最近一次傳給 :meth:`set` 的值。" #: ../../library/tkinter.rst:4962 msgid "" @@ -6507,6 +7732,9 @@ msgid "" "document. This method is normally registered as the scrolled widget's " "*xscrollcommand* or *yscrollcommand* and called by that widget." msgstr "" +"設定此 scrollbar。*first* 和 *last* 為介於 0 到 1 之間的分數,表示相關聯文件" +"中可見部分的起點與終點位置。此方法通常會被註冊為被捲動元件的 " +"*xscrollcommand* 或 *yscrollcommand*,並由該元件呼叫。" #: ../../library/tkinter.rst:4970 msgid "" @@ -6515,10 +7743,13 @@ msgid "" "*activerelief* options. If *index* is omitted, return the name of the " "currently active element, or ``None`` if no element is active." msgstr "" +"將元素 *index* (``'arrow1'``、``'slider'`` 或 ``'arrow2'`` 其中之一)標記為" +"作用中,並依照 *activebackground* 和 *activerelief* 選項顯示它。若省略 " +"*index*,則回傳目前作用中元素的名稱,若沒有元素處於作用中,則回傳 ``None``。" #: ../../library/tkinter.rst:4976 msgid "The *index* argument is now optional." -msgstr "" +msgstr "*index* 引數現在為可選。" #: ../../library/tkinter.rst:4981 msgid "" @@ -6527,6 +7758,9 @@ msgid "" "horizontal scrollbars) or *deltay* pixels vertically (for vertical " "scrollbars)." msgstr "" +"回傳一個 float,表示將滑桿水平移動 *deltax* 個像素(適用於水平 scrollbar)或" +"垂直移動 *deltay* 個像素(適用於垂直 scrollbar)時,scrollbar 設定所對應的分" +"數變化量。" #: ../../library/tkinter.rst:4988 msgid "" @@ -6534,6 +7768,8 @@ msgid "" "coordinates *x*, *y* lies in the trough: 0 corresponds to the top or left of " "the trough and 1 to the bottom or right." msgstr "" +"回傳一個介於 0 到 1 之間的 float,表示位於像素座標 *x*、*y* 處的點在溝槽中的" +"位置:0 對應溝槽的頂端或左側,1 對應底端或右側。" #: ../../library/tkinter.rst:4994 msgid "" @@ -6541,6 +7777,8 @@ msgid "" "``'arrow1'``), or an empty string if the point does not lie in any element " "of the scrollbar." msgstr "" +"回傳位於像素座標 *x*、*y* 下方元素的名稱(例如 ``'arrow1'``),若該點不在此 " +"scrollbar 的任何元素之上,則回傳空字串。" #: ../../library/tkinter.rst:5001 msgid "" @@ -6555,12 +7793,21 @@ msgid "" "numeric values are formatted; and the *validate* option enables validation " "of the entered text. Inherits from :class:`Widget` and :class:`XView`." msgstr "" +":class:`!Spinbox` 元件是一種類似 :class:`Entry` 的元件,具有一對上/下箭頭按" +"鈕,讓使用者除了可以直接編輯數值之外,還能逐步瀏覽一個數值範圍。這組數值可以" +"是由 *from_*、*to* 和 *increment* 選項所指定的數值範圍,或是由 *values* 選項" +"所指定的明確字串清單(此選項優先於範圍設定)。每次按下箭頭時,若有指定 " +"*command* 回呼,就會呼叫它;*wrap* 選項控制在超出範圍任一端時是否要繞回到另一" +"端;*format* 選項指定數值的格式化方式;而 *validate* 選項則可啟用對輸入文字的" +"驗證。繼承自 :class:`Widget` 和 :class:`XView`。" #: ../../library/tkinter.rst:5014 msgid "" "With a non-integer *increment*, see :ref:`numeric values and the locale " "`." msgstr "" +"若 *increment* 為非整數,請參閱\\ :ref:`數值與地區設定 `。" #: ../../library/tkinter.rst:5017 msgid "" @@ -6572,16 +7819,21 @@ msgid "" "last'`` (the ends of the selection), or ``@x`` (the character covering pixel " "x-coordinate *x* in the window)." msgstr "" +"許多方法都接受一個 *index* 引數,用於指定此 spinbox 字串中的某個字元。如 Tk " +"``spinbox`` 手冊頁所述,*index* 可以是一個數值索引(從 0 開始計數)、" +"``'anchor'``\\ (選取錨點)、``'end'``\\ (最後一個字元之後的位置)、" +"``'insert'``\\ (插入游標之後的字元)、``'sel.first'`` 或 ``'sel.last'``\\ " +"(選取範圍的兩端),或是 ``@x``\\ (涵蓋視窗中像素 x 座標 *x* 的字元)。" #: ../../library/tkinter.rst:5028 msgid "Return the spinbox's string." -msgstr "" +msgstr "回傳此 spinbox 的字串。" #: ../../library/tkinter.rst:5032 msgid "" "Insert the characters of the string *s* just before the character given by " "*index*." -msgstr "" +msgstr "將字串 *s* 中的字元插入到由 *index* 所指定的字元之前。" #: ../../library/tkinter.rst:5037 msgid "" @@ -6590,10 +7842,13 @@ msgid "" "after the last one to delete. If *last* is omitted, a single character at " "*first* is deleted." msgstr "" +"刪除此 spinbox 中一個或多個字元。*first* 為要刪除的第一個字元的索引,*last* " +"為要刪除的最後一個字元之後那個字元的索引。若省略 *last*,則只刪除 *first* 處" +"的單一字元。" #: ../../library/tkinter.rst:5049 msgid "Return the numerical index corresponding to *index*, as a string." -msgstr "" +msgstr "回傳對應 *index* 的數值索引,以字串形式表示。" #: ../../library/tkinter.rst:5053 msgid "" @@ -6603,18 +7858,26 @@ msgid "" "widget, and *width* and *height* are its size in pixels. The bounding box " "may refer to a region outside the visible area of the window." msgstr "" +"回傳一個包含四個整數 ``(x, y, width, height)`` 的 tuple,描述由 *index* 所指" +"定字元的邊界框(bounding box)。*x* 和 *y* 為該字元左上角相對於此元件的像素座" +"標,*width* 和 *height* 則為其以像素為單位的尺寸。此邊界框可能是指視窗可見區" +"域之外的範圍。" #: ../../library/tkinter.rst:5066 msgid "" "Return the name of the window element at the pixel coordinates *x*, *y*: one " "of ``'buttondown'``, ``'buttonup'``, ``'entry'`` or ``'none'``." msgstr "" +"回傳位於像素座標 *x*、*y* 處視窗元素的名稱:``'buttondown'``、" +"``'buttonup'``、``'entry'`` 或 ``'none'`` 其中之一。" #: ../../library/tkinter.rst:5071 msgid "" "Invoke the spin button given by *element*, either ``'buttonup'`` or " "``'buttondown'``, triggering the action associated with it." msgstr "" +"叫用由 *element* 所指定的旋轉按鈕(``'buttonup'`` 或 ``'buttondown'`` 其中之" +"一),觸發與其相關聯的動作。" #: ../../library/tkinter.rst:5076 msgid "" @@ -6623,6 +7886,10 @@ msgid "" "view, and ``scan('dragto', x)`` adjusts the view relative to that mark. The :" "meth:`scan_mark` and :meth:`scan_dragto` methods wrap the two forms." msgstr "" +"這是 Tk ``scan`` 元件子指令的薄封裝,用於實作快速拖曳檢視畫面:" +"``scan('mark', x)`` 會記錄 *x* 與目前的檢視畫面,而 ``scan('dragto', x)`` 則" +"會相對於該標記調整檢視畫面。:meth:`scan_mark` 和 :meth:`scan_dragto` 方法即為" +"這兩種形式的封裝。" #: ../../library/tkinter.rst:5084 msgid "" @@ -6630,6 +7897,8 @@ msgid "" "meth:`scan_dragto` call. This is typically associated with a mouse button " "press in the widget." msgstr "" +"記錄 *x* 與此 spinbox 視窗目前的檢視畫面,供之後呼叫 :meth:`scan_dragto` 時使" +"用。這通常會與元件中的滑鼠按鍵按下事件相關聯。" #: ../../library/tkinter.rst:5090 msgid "" @@ -6638,6 +7907,9 @@ msgid "" "motion events, producing the effect of dragging the spinbox at high speed " "through the window." msgstr "" +"依據 *x* 與最近一次呼叫 :meth:`scan_mark` 時所傳入之 *x* 之間差值的 10 倍來調" +"整檢視畫面。這通常會與滑鼠移動事件相關聯,產生以高速拖曳此 spinbox 穿過視窗的" +"效果。" #: ../../library/tkinter.rst:5097 msgid "" @@ -6651,6 +7923,14 @@ msgid "" "meth:`selection_present`, :meth:`selection_range` and :meth:`selection_to` " "methods wrap these forms." msgstr "" +"這是 Tk ``selection`` 元件子指令的薄封裝,用於調整此 spinbox 中的選取範圍。依" +"第一個引數的不同,它有數種形式,例如 ``selection('adjust', index)``、" +"``selection('clear')``、``selection('element', ?elem?)``、" +"``selection('from', index)``、``selection('present')``、``selection('range', " +"start, end)`` 和 ``selection('to', index)``。:meth:`selection_adjust`、:meth:" +"`selection_clear`、:meth:`selection_element`、:meth:`selection_from`、:meth:" +"`selection_present`、:meth:`selection_range` 和 :meth:`selection_to` 方法即為" +"這些形式的封裝。" #: ../../library/tkinter.rst:5111 msgid "" @@ -6661,18 +7941,26 @@ msgid "" "a new selection is created to include the characters between *index* and the " "most recent anchor point, inclusive." msgstr "" +"找出選取範圍中最靠近 *index* 所指定字元的那一端,並將該端調整到 *index* 處" +"(包含但不超過 *index*)。另一端則會成為之後呼叫 :meth:`selection_to` 時的錨" +"點。若此 spinbox 目前沒有選取範圍,則會建立一個新的選取範圍,包含 *index* 與" +"最近錨點之間(含兩端)的字元。" #: ../../library/tkinter.rst:5122 msgid "" "Clear the selection if it is currently in this widget. If the selection is " "not in this widget, the method has no effect." msgstr "" +"若此元件目前有選取範圍,則清除該選取範圍。若此元件沒有選取範圍,則此方法沒有" +"作用。" #: ../../library/tkinter.rst:5127 msgid "" "This shadows the inherited :meth:`Misc.selection_clear`, which clears the X " "selection; that method is not available on a :class:`Spinbox`." msgstr "" +"這會遮蔽繼承而來的 :meth:`Misc.selection_clear`\\ (用於清除 X selection);" +"該方法在 :class:`Spinbox` 上無法使用。" #: ../../library/tkinter.rst:5133 msgid "" @@ -6681,18 +7969,22 @@ msgid "" "is selected and displayed depressed; otherwise the name of the currently " "selected element is returned." msgstr "" +"設定或取得目前選取的元素。若有給定 *element* (``'buttonup'``、" +"``'buttondown'`` 或 ``'none'`` 其中之一),則會選取該旋轉按鈕並以按下的樣式顯" +"示;否則會回傳目前選取元素的名稱。" #: ../../library/tkinter.rst:5140 msgid "" "Set the selection anchor point to just before the character given by " "*index*, without changing the selection itself." msgstr "" +"將選取錨點設為緊接在 *index* 所指定字元之前的位置,但不改變選取範圍本身。" #: ../../library/tkinter.rst:5148 msgid "" "Return ``True`` if there are characters selected in the spinbox, ``False`` " "otherwise." -msgstr "" +msgstr "若此 spinbox 中有已選取的字元則回傳 ``True``,否則回傳 ``False``。" #: ../../library/tkinter.rst:5156 msgid "" @@ -6700,6 +7992,8 @@ msgid "" "*start* and ending with the one just before *end*. If *end* refers to the " "same character as *start* or an earlier one, the selection is cleared." msgstr "" +"將選取範圍設為包含從 *start* 索引的字元開始,到 *end* 之前那個字元為止的所有" +"字元。若 *end* 所指的字元與 *start* 相同或位於其之前,則會清除選取範圍。" #: ../../library/tkinter.rst:5166 msgid "" @@ -6711,6 +8005,11 @@ msgid "" "meth:`selection_adjust` call. If the selection is not in this widget, a new " "selection is created using the most recent anchor point." msgstr "" +"將選取範圍設為 *index* 與錨點之間的範圍。若 *index* 位於錨點之前,選取範圍會" +"從 *index* 開始,直到但不包含錨點;若位於其後,選取範圍會從錨點開始,直到但不" +"包含 *index*;若兩者相同,則不會有任何動作。錨點為最近一次呼叫 :meth:" +"`selection_from` 或 :meth:`selection_adjust` 時所設定的位置。若此元件沒有選取" +"範圍,則會使用最近的錨點建立一個新的選取範圍。" #: ../../library/tkinter.rst:5182 msgid "" @@ -6724,6 +8023,13 @@ msgid "" "`~YView.yview`. Refer to the Tk ``text`` manual page for the full list of " "options." msgstr "" +":class:`!Text` 元件用於顯示與編輯多行文字。文字的部分內容可以用\\ **標籤**\\ " +"(tag)加以樣式化,特定位置可以用浮動的\\ **標記**\\ (mark)加以標註,此外還" +"可以在文字中嵌入任意的圖片與其他元件。此元件也提供不受限制的復原/重做機制," +"並支援共用相同底層資料的同儕元件(peer widget)。繼承自 :class:`Widget`、:" +"class:`XView` 和 :class:`YView`,因此可以用 :meth:`~XView.xview` 和 :meth:" +"`~YView.yview` 對檢視畫面進行水平和垂直捲動。完整的選項清單請參閱 Tk 的 " +"``text`` 手冊頁。" #: ../../library/tkinter.rst:5193 msgid "" @@ -6742,6 +8048,17 @@ msgid "" "to its base; several modifiers may be combined and are applied from left to " "right, for example ``'insert wordstart - 1 c'``." msgstr "" +"大多數方法都接受一個或多個 *index* 引數,用於指定文字中的某個位置。如 Tk " +"``text`` 手冊頁所述,索引是一個由基底(base)組成的字串,後面可選擇性地接上一" +"個或多個修飾詞(modifier)。基底可以是 ``'line.char'``\\ (第 *line* 行、第 " +"*char* 個字元,其中行號從 1 開始計數,行內字元則從 0 開始計數;``'line." +"end'`` 表示該行結尾的換行字元)、``'end'``\\ (最後一個換行字元之後的位置)、" +"標記的名稱、``'tag.first'`` 或 ``'tag.last'``\\ (標有 *tag* 標籤的第一個字" +"元,或是最後一個這類字元之後的位置)、嵌入圖片或視窗的名稱,或是 ``@x,y``\\ " +"(涵蓋此元件中像素座標 *x*、*y* 的字元)。像 ``'+5 chars'``、``'-3 lines'``、" +"``'linestart'``、``'lineend'``、``'wordstart'`` 或 ``'wordend'`` 這樣的修飾詞" +"會相對於其基底調整該索引;多個修飾詞可以組合使用,並由左至右依序套用,例如 " +"``'insert wordstart - 1 c'``。" #: ../../library/tkinter.rst:5211 msgid "" @@ -6752,6 +8069,11 @@ msgid "" "*chars* receives exactly the tags listed (a tag list may be a single tag " "name or a sequence of names), overriding the surrounding tags." msgstr "" +"將字串 *chars* 插入到 *index* 處字元之前(若 *index* 為 ``'end'``,則插入到最" +"後一個換行字元之前)。預設情況下,新文字會繼承插入點兩側都存在的所有標籤。若" +"有給定 *args*,則其由交替出現的 *tagList*、*chars* 值所組成:前一個 *chars* " +"會精確套用所列出的標籤(標籤清單可以是單一標籤名稱,或是一連串名稱),並覆蓋" +"周圍的標籤。" #: ../../library/tkinter.rst:5222 msgid "" @@ -6760,6 +8082,9 @@ msgid "" "deleted. The widget always keeps a newline as its last character, so a " "deletion that would remove it is adjusted accordingly." msgstr "" +"刪除從 *index1* 開始、直到但不包含 *index2* 的字元範圍。若省略 *index2*,則只" +"刪除 *index1* 處的單一字元。此元件的最後一個字元一律會保留換行字元,因此若刪" +"除動作會移除該字元,則會相應地調整刪除範圍。" #: ../../library/tkinter.rst:5230 msgid "" @@ -6767,6 +8092,9 @@ msgid "" "*index2* with *chars*. This is equivalent to a :meth:`delete` followed by " "an :meth:`insert` at *index1*; *args* is interpreted as for :meth:`insert`." msgstr "" +"將從 *index1* 開始、直到但不包含 *index2* 的字元範圍替換為 *chars*。這相當於" +"先呼叫 :meth:`delete`,再於 *index1* 處呼叫 :meth:`insert`;*args* 的解讀方式" +"與 :meth:`insert` 相同。" #: ../../library/tkinter.rst:5239 msgid "" @@ -6774,12 +8102,14 @@ msgid "" "If *index2* is omitted, return the single character at *index1*. Embedded " "images and windows are omitted from the result." msgstr "" +"以字串形式回傳從 *index1* 開始、直到但不包含 *index2* 的文字。若省略 " +"*index2*,則回傳 *index1* 處的單一字元。結果中不包含嵌入的圖片與視窗。" #: ../../library/tkinter.rst:5246 msgid "" "Return the position corresponding to *index* in the canonical ``'line." "char'`` form." -msgstr "" +msgstr "以標準的 ``'line.char'`` 形式回傳對應 *index* 的位置。" #: ../../library/tkinter.rst:5251 msgid "" @@ -6787,6 +8117,8 @@ msgid "" "*op*, which must be one of ``'<'``, ``'<='``, ``'=='``, ``'>='``, ``'>'`` or " "``'!='``, and return the boolean result." msgstr "" +"使用關係運算子 *op* (必須是 ``'<'``、``'<='``、``'=='``、``'>='``、``'>'`` " +"或 ``'!='`` 其中之一)比較 *index1* 和 *index2* 的位置,並回傳布林結果。" #: ../../library/tkinter.rst:5257 msgid "" @@ -6801,10 +8133,18 @@ msgid "" "return a plain integer; otherwise return a tuple with one integer per " "counting option (or ``None`` if the result is empty)." msgstr "" +"計算 *index1* 和 *index2* 之間所要求種類的項目數量;若 *index1* 在 *index2* " +"之後,則計數為負值。*options* 中的每一項都用於指定要計算的項目種類:" +"``'chars'``、``'displaychars'``、``'displayindices'``、``'displaylines'``、" +"``'indices'``、``'lines'``、``'xpixels'`` 或 ``'ypixels'``\\ (若未給定任何選" +"項,預設值為 ``'indices'``)。虛擬選項 ``'update'`` 會強制在計算後續選項之" +"前,重新計算任何過時的版面配置資訊。當 *return_ints* 為真且只給定一個計數選項" +"時,回傳一個純 int;否則回傳一個 tuple,其中每個計數選項各對應一個 int(若結" +"果為空則回傳 ``None``)。" #: ../../library/tkinter.rst:5271 msgid "Added the *return_ints* parameter." -msgstr "" +msgstr "新增 *return_ints* 參數。" #: ../../library/tkinter.rst:5277 msgid "" @@ -6813,6 +8153,9 @@ msgid "" "view the widget scrolls just enough to bring it to the nearest edge, " "otherwise it scrolls to center *index* in the window." msgstr "" +"調整檢視畫面,使 *index* 所指定的字元可見。若該字元已經可見,此方法沒有作用;" +"若該字元只稍微超出可見範圍,此元件只會捲動剛好足夠的距離,使其到達最近的邊" +"緣;否則會捲動至讓 *index* 位於視窗正中央。" #: ../../library/tkinter.rst:5284 msgid "" @@ -6820,6 +8163,8 @@ msgid "" "of the visible part of the character at *index*, or ``None`` if that " "character is not visible on the screen." msgstr "" +"回傳一個 tuple ``(x, y, width, height)``,以像素為單位表示 *index* 處字元可見" +"部分的邊界框,若該字元在螢幕上不可見,則回傳 ``None``。" #: ../../library/tkinter.rst:5293 msgid "" @@ -6829,6 +8174,9 @@ msgid "" "down from the top of the area. Return ``None`` if that display line is not " "visible on the screen." msgstr "" +"回傳一個 tuple ``(x, y, width, height, baseline)``,描述包含 *index* 的顯示" +"行:前四個值以像素表示該行的邊界框,*baseline* 則表示基準線相對於該區域頂端往" +"下量測的偏移量。若該顯示行在螢幕上不可見,則回傳 ``None``。" #: ../../library/tkinter.rst:5301 msgid "" @@ -6836,16 +8184,20 @@ msgid "" "*index*, creating the mark if it does not already exist. A mark created this " "way has right gravity by default." msgstr "" +"將名為 *markName* 的標記設定到 *index* 處字元之前的位置,若該標記尚不存在則會" +"建立它。以此方式建立的標記預設具有右側引力(right gravity)。" #: ../../library/tkinter.rst:5307 msgid "" "Remove each of the marks named in *markNames*. The special ``insert`` and " "``current`` marks may not be removed." msgstr "" +"移除 *markNames* 中所指定名稱的每個標記。特殊的 ``insert`` 和 ``current`` 標" +"記無法被移除。" #: ../../library/tkinter.rst:5312 msgid "Return a tuple of the names of all marks currently set in the widget." -msgstr "" +msgstr "回傳此元件中目前所有已設定標記名稱所組成的 tuple。" #: ../../library/tkinter.rst:5316 msgid "" @@ -6855,6 +8207,10 @@ msgid "" "position appears: a mark with right gravity (the default) stays to the right " "of such text." msgstr "" +"若省略 *direction*,則回傳標記 *markName* 的引力,為 ``'left'`` 或 " +"``'right'`` 之一。否則將其引力設為 *direction*。引力決定在該標記位置插入文字" +"時,插入的文字會出現在標記的哪一側:具有右側引力(預設值)的標記會保持在此類" +"文字的右側。" #: ../../library/tkinter.rst:5325 msgid "" @@ -6862,6 +8218,8 @@ msgid "" "is none. When *index* is the name of a mark, the search starts just after " "that mark." msgstr "" +"回傳位於 *index* 或其之後的第一個標記名稱,若沒有這樣的標記則回傳 ``None``。" +"若 *index* 為某個標記的名稱,則搜尋會從該標記之後開始。" #: ../../library/tkinter.rst:5332 msgid "" @@ -6869,6 +8227,8 @@ msgid "" "is none. When *index* is the name of a mark, the search starts just before " "that mark." msgstr "" +"回傳位於 *index* 或其之前的最後一個標記名稱,若沒有這樣的標記則回傳 " +"``None``。若 *index* 為某個標記的名稱,則搜尋會從該標記之前開始。" #: ../../library/tkinter.rst:5339 msgid "" @@ -6877,6 +8237,9 @@ msgid "" "*args* to tag additional ranges; a trailing single index tags just the " "character at that index." msgstr "" +"將標籤 *tagName* 加入到從 *index1* 開始、直到但不包含 *args* 中下一個索引的字" +"元範圍。*args* 中可以接續更多索引配對,用來標記其他範圍;若結尾為單一索引,則" +"只會標記該索引處的字元。" #: ../../library/tkinter.rst:5346 msgid "" @@ -6884,12 +8247,17 @@ msgid "" "including *index2* (or from the single character at *index1* if *index2* is " "omitted). The tag itself continues to exist even if no characters carry it." msgstr "" +"從 *index1* 開始、直到但不包含 *index2* 的字元中移除標籤 *tagName* (若省略 " +"*index2*,則只從 *index1* 處的單一字元移除)。即使沒有任何字元帶有該標籤,該" +"標籤本身仍會繼續存在。" #: ../../library/tkinter.rst:5353 msgid "" "Delete each of the tags named in *tagNames*, removing them from all " "characters and discarding their options and bindings." msgstr "" +"刪除 *tagNames* 中所指定名稱的每個標籤,將它們從所有字元中移除,並捨棄其選項" +"與繫結。" #: ../../library/tkinter.rst:5361 msgid "" @@ -6899,48 +8267,53 @@ msgid "" "the current options, otherwise it sets the given options. Defining a tag " "this way also gives it a priority higher than any existing tag." msgstr "" +"查詢或修改標籤 *tagName* 的設定選項。此方法與 :meth:`~Misc.configure` 相似," +"差別在於它作用於某個標籤,而非整個元件:若未提供任何選項,會回傳一個描述目前" +"選項的 dictionary;否則會設定所給定的選項。以此方式定義標籤,也會使其優先權高" +"於任何現有的標籤。" #: ../../library/tkinter.rst:5369 msgid "" "The supported tag options, all controlling the appearance of the tagged " "text, are:" -msgstr "" +msgstr "支援的標籤選項如下,皆用於控制標記文字的外觀:" #: ../../library/tkinter.rst:5375 msgid "*foreground*" -msgstr "" +msgstr "*foreground*" #: ../../library/tkinter.rst:5376 msgid "The color to use for the text." -msgstr "" +msgstr "用於文字的顏色。" #: ../../library/tkinter.rst:5378 msgid "*background*" -msgstr "" +msgstr "*background*" #: ../../library/tkinter.rst:5379 msgid "The color to use for the area behind the text." -msgstr "" +msgstr "用於文字背後區域的顏色。" #: ../../library/tkinter.rst:5381 msgid "*fgstipple*, *bgstipple*" -msgstr "" +msgstr "*fgstipple*, *bgstipple*" #: ../../library/tkinter.rst:5382 msgid "" "Bitmaps used to stipple the foreground (text) and the background; only well " "supported on X11." msgstr "" +"用於為前景(文字)與背景加上點紋效果的點陣圖;僅在 X11 上有良好的支援。" #: ../../library/tkinter.rst:5385 msgid "*borderwidth*" -msgstr "" +msgstr "*borderwidth*" #: ../../library/tkinter.rst:5386 msgid "" "The width of the border drawn around the text according to *relief* (default " "``0``)." -msgstr "" +msgstr "依照 *relief* 在文字周圍繪製的邊框寬度(預設為 ``0``)。" #: ../../library/tkinter.rst:5389 msgid "*relief*" @@ -6951,58 +8324,61 @@ msgid "" "The 3-D appearance of the text's border: ``'flat'`` (the default), " "``'raised'``, ``'sunken'``, ``'ridge'``, ``'groove'`` or ``'solid'``." msgstr "" +"文字邊框的立體外觀:``'flat'``\\ (預設)、``'raised'``、``'sunken'``、" +"``'ridge'``、``'groove'`` 或 ``'solid'``。" #: ../../library/tkinter.rst:5393 msgid "*offset*" -msgstr "" +msgstr "*offset*" #: ../../library/tkinter.rst:5394 msgid "" "How far the text is raised above (or, if negative, lowered below) the " "baseline, for superscripts and subscripts." -msgstr "" +msgstr "文字相對於基準線抬升(若為負值則為下降)的距離,用於上標與下標。" #: ../../library/tkinter.rst:5398 msgid "Whether to underline the text." -msgstr "" +msgstr "是否為文字加上底線。" #: ../../library/tkinter.rst:5400 msgid "*underlinefg*" -msgstr "" +msgstr "*underlinefg*" #: ../../library/tkinter.rst:5401 msgid "The color of the underline; it defaults to the text color." -msgstr "" +msgstr "底線的顏色;預設為文字的顏色。" #: ../../library/tkinter.rst:5403 msgid "*overstrike*" -msgstr "" +msgstr "*overstrike*" #: ../../library/tkinter.rst:5404 msgid "Whether to draw a line through the middle of the text." -msgstr "" +msgstr "是否在文字中間畫一條線。" #: ../../library/tkinter.rst:5406 msgid "*overstrikefg*" -msgstr "" +msgstr "*overstrikefg*" #: ../../library/tkinter.rst:5407 msgid "The color of the overstrike line; it defaults to the text color." -msgstr "" +msgstr "刪除線的顏色;預設為文字的顏色。" #: ../../library/tkinter.rst:5409 msgid "*elide*" -msgstr "" +msgstr "*elide*" #: ../../library/tkinter.rst:5410 msgid "Whether the text is elided (hidden)." -msgstr "" +msgstr "文字是否被省略(隱藏)。" #: ../../library/tkinter.rst:5413 msgid "" "How to justify the first character of a display line: ``'left'`` (the " "default), ``'right'`` or ``'center'``." msgstr "" +"顯示行首字元的對齊方式:``'left'``\\ (預設)、``'right'`` 或 ``'center'``。" #: ../../library/tkinter.rst:5416 msgid "*wrap*" @@ -7011,92 +8387,96 @@ msgstr "*wrap*" #: ../../library/tkinter.rst:5417 msgid "" "How to wrap lines that are too long: ``'char'``, ``'word'`` or ``'none'``." -msgstr "" +msgstr "過長行的換行方式:``'char'``、``'word'`` 或 ``'none'``。" #: ../../library/tkinter.rst:5420 msgid "*lmargin1*, *lmargin2*" -msgstr "" +msgstr "*lmargin1*, *lmargin2*" #: ../../library/tkinter.rst:5421 msgid "" "The indentation, in pixels, of the first display line of a logical line and " "of the remaining display lines." -msgstr "" +msgstr "邏輯行第一個顯示行,以及其餘顯示行的縮排量,以像素為單位。" #: ../../library/tkinter.rst:5424 msgid "*lmargincolor*" -msgstr "" +msgstr "*lmargincolor*" #: ../../library/tkinter.rst:5425 msgid "The color of the left margin area." -msgstr "" +msgstr "左邊界區域的顏色。" #: ../../library/tkinter.rst:5427 msgid "*rmargin*" -msgstr "" +msgstr "*rmargin*" #: ../../library/tkinter.rst:5428 msgid "The right-hand margin, in pixels." -msgstr "" +msgstr "右邊界,以像素為單位。" #: ../../library/tkinter.rst:5430 msgid "*rmargincolor*" -msgstr "" +msgstr "*rmargincolor*" #: ../../library/tkinter.rst:5431 msgid "The color of the right margin area." -msgstr "" +msgstr "右邊界區域的顏色。" #: ../../library/tkinter.rst:5433 msgid "*spacing1*, *spacing2*, *spacing3*" -msgstr "" +msgstr "*spacing1*, *spacing2*, *spacing3*" #: ../../library/tkinter.rst:5434 msgid "" "Extra space, in pixels, above the first display line of a logical line, " "between its display lines, and below its last display line." msgstr "" +"邏輯行第一個顯示行上方、各顯示行之間,以及最後一個顯示行下方的額外空間,以像" +"素為單位。" #: ../../library/tkinter.rst:5437 msgid "*tabs*" -msgstr "" +msgstr "*tabs*" #: ../../library/tkinter.rst:5438 msgid "The set of tab stops, in the same form as the widget's *tabs* option." -msgstr "" +msgstr "定位停駐點的集合,格式與此元件的 *tabs* 選項相同。" #: ../../library/tkinter.rst:5440 msgid "*tabstyle*" -msgstr "" +msgstr "*tabstyle*" #: ../../library/tkinter.rst:5441 msgid "How tab stops are interpreted: ``'tabular'`` or ``'wordprocessor'``." -msgstr "" +msgstr "定位停駐點的解讀方式:``'tabular'`` 或 ``'wordprocessor'``。" #: ../../library/tkinter.rst:5443 msgid "*selectbackground*, *selectforeground*" -msgstr "" +msgstr "*selectbackground*, *selectforeground*" #: ../../library/tkinter.rst:5444 msgid "" "The background and foreground colors used for the text while it is selected." -msgstr "" +msgstr "文字被選取時所使用的背景與前景顏色。" #: ../../library/tkinter.rst:5449 msgid "" "Tk 8.6 added the *lmargincolor*, *overstrikefg*, *rmargincolor*, " "*selectbackground*, *selectforeground* and *underlinefg* options." msgstr "" +"Tk 8.6 新增了 *lmargincolor*、*overstrikefg*、*rmargincolor*、" +"*selectbackground*、*selectforeground* 和 *underlinefg* 選項。" #: ../../library/tkinter.rst:5452 msgid ":meth:`tag_config` is an alias of :meth:`!tag_configure`." -msgstr "" +msgstr ":meth:`tag_config` 是 :meth:`!tag_configure` 的別名。" #: ../../library/tkinter.rst:5456 msgid "" "Return the current value of the configuration option *option* for the tag " "*tagName*." -msgstr "" +msgstr "回傳標籤 *tagName* 的設定選項 *option* 目前的值。" #: ../../library/tkinter.rst:5461 msgid "" @@ -7104,6 +8484,8 @@ msgid "" "the widget; otherwise return only the names of the tags applied to the " "character at *index*. The names are ordered from lowest to highest priority." msgstr "" +"若省略 *index*,則回傳此元件中所有已定義標籤名稱所組成的 tuple;否則只回傳套" +"用於 *index* 處字元的標籤名稱。這些名稱依優先權由低到高排序。" #: ../../library/tkinter.rst:5468 msgid "" @@ -7111,6 +8493,8 @@ msgid "" "*tagName*. The result alternates start and end indices, so that elements " "``2*i`` and ``2*i+1`` bound the *i*-th range." msgstr "" +"回傳一個由索引組成的 tuple,描述所有標有 *tagName* 標籤的文字範圍。結果中的起" +"始與結束索引交替出現,因此元素 ``2*i`` 和 ``2*i+1`` 界定了第 *i* 個範圍。" #: ../../library/tkinter.rst:5475 msgid "" @@ -7118,6 +8502,9 @@ msgid "" "of characters tagged with *tagName*, and return a two-element tuple of its " "start and end indices, or an empty tuple if there is no such range." msgstr "" +"從 *index1* 開始向前搜尋(若有給定 *index2*,則搜尋至該處為止),尋找第一個標" +"有 *tagName* 標籤的字元範圍,並回傳一個包含其起始與結束索引的二元素 tuple;若" +"沒有這樣的範圍,則回傳空 tuple。" #: ../../library/tkinter.rst:5482 msgid "" @@ -7126,6 +8513,9 @@ msgid "" "element tuple of its start and end indices, or an empty tuple if there is no " "such range." msgstr "" +"從 *index1* 開始向後搜尋(若有給定 *index2*,則搜尋至該處為止),尋找最靠近的" +"前一個標有 *tagName* 標籤的字元範圍,並回傳一個包含其起始與結束索引的二元素 " +"tuple;若沒有這樣的範圍,則回傳空 tuple。" #: ../../library/tkinter.rst:5489 msgid "" @@ -7134,12 +8524,17 @@ msgid "" "omitted. When the display options of overlapping tags conflict, the higher-" "priority tag wins." msgstr "" +"提高標籤 *tagName* 的優先權,使其剛好高於 *aboveThis* 的優先權;若省略 " +"*aboveThis*,則將其優先權提高至所有標籤中最高。當重疊標籤的顯示選項發生衝突" +"時,優先權較高的標籤將會勝出。" #: ../../library/tkinter.rst:5497 msgid "" "Lower the priority of tag *tagName* so that it is just below the priority of " "*belowThis*, or to the lowest priority of all tags if *belowThis* is omitted." msgstr "" +"降低標籤 *tagName* 的優先權,使其剛好低於 *belowThis* 的優先權;若省略 " +"*belowThis*,則將其優先權降低至所有標籤中最低。" #: ../../library/tkinter.rst:5503 msgid "" @@ -7149,6 +8544,10 @@ msgid "" "bindings for *sequence*, otherwise it replaces them. Works like :meth:`~Misc." "bind` and returns the identifier of the new binding." msgstr "" +"將事件 *sequence* 繫結到標有 *tagName* 標籤的字元上的回呼 *func*,使得該事件" +"發生於這類字元之上時會叫用 *func*。若 *add* 為真,此繫結會新增在 *sequence* " +"現有繫結之外;否則會取代它們。運作方式與 :meth:`~Misc.bind` 相同,並回傳新繫" +"結的識別碼。" #: ../../library/tkinter.rst:5513 msgid "" @@ -7156,6 +8555,8 @@ msgid "" "*tagName*. If *funcid* is given, only that binding (as returned by :meth:" "`tag_bind`) is removed and its callback is unregistered." msgstr "" +"移除標有 *tagName* 標籤字元上事件 *sequence* 的繫結。若有給定 *funcid*,則只" +"會移除該繫結(即 :meth:`tag_bind` 所回傳的繫結),並取消註冊其回呼函式。" #: ../../library/tkinter.rst:5524 msgid "" @@ -7165,22 +8566,28 @@ msgid "" "(the Tk image to display), *name* (a base name for the instance), *align*, " "*padx* and *pady*." msgstr "" +"在 *index* 處嵌入一張圖片,並回傳指派給此圖片實例的名稱,之後即可將該名稱當作" +"索引使用,或傳遞給其他 ``image_*`` 方法。透過 *cnf* 和 *kw* 給定的選項包括 " +"*image* (要顯示的 Tk 圖片)、*name* (此實例的基本名稱)、*align*、*padx* " +"和 *pady*。" #: ../../library/tkinter.rst:5533 msgid "" "Return the current value of the configuration option *option* for the " "embedded image at *index*." -msgstr "" +msgstr "回傳 *index* 處嵌入圖片的設定選項 *option* 目前的值。" #: ../../library/tkinter.rst:5538 msgid "" "Query or modify the configuration options of the embedded image at *index*, " "like :meth:`~Misc.configure` but applied to that image." msgstr "" +"查詢或修改 *index* 處嵌入圖片的設定選項,作用方式與 :meth:`~Misc.configure` " +"相似,但作用於該圖片。" #: ../../library/tkinter.rst:5543 msgid "Return a tuple of the names of all images embedded in the widget." -msgstr "" +msgstr "回傳此元件中所有嵌入圖片名稱所組成的 tuple。" #: ../../library/tkinter.rst:5547 msgid "" @@ -7188,6 +8595,8 @@ msgid "" "of all images in the Tcl interpreter; that method is not available on a :" "class:`Text`." msgstr "" +"這會遮蔽繼承而來的 :meth:`Misc.image_names`\\ (用於回傳 Tcl 直譯器中所有圖片" +"的名稱);該方法在 :class:`Text` 上無法使用。" #: ../../library/tkinter.rst:5553 msgid "" @@ -7196,26 +8605,31 @@ msgid "" "creates the widget on demand), *align*, *stretch*, *padx* and *pady*. The " "embedded widget must be a descendant of the text widget's parent." msgstr "" +"在 *index* 處嵌入一個視窗(任何元件)。透過 *cnf* 和 *kw* 給定的選項包括 " +"*window* (要嵌入的元件)、*create* (依需求建立該元件的回呼)、*align*、" +"*stretch*、*padx* 和 *pady*。嵌入的元件必須是此 text 元件之父元件的子代。" #: ../../library/tkinter.rst:5561 msgid "" "Return the current value of the configuration option *option* for the " "embedded window at *index*." -msgstr "" +msgstr "回傳 *index* 處嵌入視窗的設定選項 *option* 目前的值。" #: ../../library/tkinter.rst:5569 msgid "" "Query or modify the configuration options of the embedded window at *index*, " "like :meth:`~Misc.configure` but applied to that window." msgstr "" +"查詢或修改 *index* 處嵌入視窗的設定選項,作用方式與 :meth:`~Misc.configure` " +"相似,但作用於該視窗。" #: ../../library/tkinter.rst:5572 msgid ":meth:`window_config` is an alias of :meth:`!window_configure`." -msgstr "" +msgstr ":meth:`window_config` 是 :meth:`!window_configure` 的別名。" #: ../../library/tkinter.rst:5576 msgid "Return a tuple of the names of all windows embedded in the widget." -msgstr "" +msgstr "回傳此元件中所有嵌入視窗名稱所組成的 tuple。" #: ../../library/tkinter.rst:5580 msgid "" @@ -7224,6 +8638,9 @@ msgid "" "and its arguments. The :meth:`!edit_\\*` methods below are thin wrappers " "around it and are usually more convenient." msgstr "" +"這是 Tk ``edit`` 元件指令的低階封裝,用於控制復原/重做機制與已修改旗標;" +"*args* 為 ``edit`` 子指令及其引數。下方的 :meth:`!edit_\\*` 方法是它的薄封" +"裝,通常較為方便使用。" #: ../../library/tkinter.rst:5588 msgid "" @@ -7231,6 +8648,8 @@ msgid "" "or false; the flag is set automatically whenever the text is inserted or " "deleted. Otherwise set the flag to the boolean *arg*." msgstr "" +"若省略 *arg*,則以 ``0`` 或 ``1`` 回傳已修改旗標目前的狀態;每當文字被插入或" +"刪除時,此旗標都會自動設定。否則將該旗標設為布林值 *arg*。" #: ../../library/tkinter.rst:5595 msgid "" @@ -7240,6 +8659,10 @@ msgid "" "unless the *undo* option is true. Since Tk 9.0, returns a tuple of indices " "delimiting the ranges of text that were changed." msgstr "" +"復原最近一次的編輯動作,也就是自上一個分隔符(separator)以來,記錄在復原堆疊" +"上的所有插入與刪除動作,並將其移至重做堆疊。若復原堆疊為空,則引發 :exc:" +"`TclError`。除非 *undo* 選項為真,否則此方法沒有作用。自 Tk 9.0 起,會回傳一" +"個索引 tuple,用於界定發生變更的文字範圍。" #: ../../library/tkinter.rst:5605 msgid "" @@ -7249,10 +8672,14 @@ msgid "" "Since Tk 9.0, returns a tuple of indices delimiting the ranges of text that " "were changed." msgstr "" +"只要在此之後沒有進行其他編輯,就重新套用最近一次被復原的編輯動作,並將其移回" +"復原堆疊。若重做堆疊為空,則引發 :exc:`TclError`。除非 *undo* 選項為真,否則" +"此方法沒有作用。自 Tk 9.0 起,會回傳一個索引 tuple,用於界定發生變更的文字範" +"圍。" #: ../../library/tkinter.rst:5614 msgid "Clear the undo and redo stacks." -msgstr "" +msgstr "清除復原與重做堆疊。" #: ../../library/tkinter.rst:5618 msgid "" @@ -7261,6 +8688,9 @@ msgid "" "Separators are inserted automatically when the *autoseparators* option is " "true." msgstr "" +"將一個分隔符推入復原堆疊,用於標記復原與重做編輯動作之間的邊界。除非 *undo* " +"選項為真,否則此方法沒有作用。當 *autoseparators* 選項為真時,會自動插入分隔" +"符。" #: ../../library/tkinter.rst:5626 msgid "" @@ -7275,6 +8705,13 @@ msgid "" "*count* is a :class:`Variable`, the number of index positions in the match " "is stored in it." msgstr "" +"從 *index* 開始搜尋 *pattern*,並回傳第一個相符結果之第一個字元的索引,若沒有" +"相符結果則回傳空字串。若有給定 *stopindex*,搜尋會在該處停止;否則會在文字的" +"兩端循環搜尋,直到再次回到起始位置為止。下列布林關鍵字旗標可用於控制搜尋:" +"*forwards* 或 *backwards* 選擇搜尋方向(預設為向前);*exact* (預設)或 " +"*regexp* 選擇字面比對或正規表示式比對;*nocase* 使比對不區分大小寫;而 " +"*elide* 會使隱藏文字也一併被搜尋。若 *count* 為 :class:`Variable`,則相符結果" +"中的索引位置數量會被存入其中。" #: ../../library/tkinter.rst:5648 msgid "" @@ -7283,6 +8720,8 @@ msgid "" "bound to mouse motion events, producing the effect of dragging the text at " "high speed through the window." msgstr "" +"依據 *x*、*y* 與最近一次呼叫 :meth:`scan_mark` 時所傳入座標之間差值的 10 倍來" +"捲動此元件。這通常會繫結至滑鼠移動事件,產生以高速拖曳文字穿過視窗的效果。" #: ../../library/tkinter.rst:5655 msgid "" @@ -7291,6 +8730,9 @@ msgid "" "setting is shared by all text widgets and may noticeably slow down widgets " "holding large amounts of text." msgstr "" +"如果省略 *boolean*,則回傳是否已啟用 B-tree 資料結構的內部一致性檢查;否則會" +"啟用或停用這些檢查。此設定由所有文字元件共用,且可能會明顯拖慢持有大量文字之" +"元件的執行速度。" #: ../../library/tkinter.rst:5663 msgid "" @@ -7304,6 +8746,14 @@ msgid "" "selected kinds. If *command* is given, it is called once per triple with the " "three values as arguments and nothing is returned." msgstr "" +"回傳元件從 *index1* 到(但不包括)*index2* 之間的內容(如果省略 *index2*,則" +"只回傳 *index1* 處的片段),包括文字以及有關標記、標籤、圖片和視窗的資訊。結" +"果是一個由 ``(key, value, index)`` 三元組組成的 list,其中 *key* 為 " +"``'text'``、``'mark'``、``'tagon'``、``'tagoff'``、``'image'`` 或 " +"``'window'``\\ 之一。預設情況下會回報所有種類;將關鍵字引數 *all*、*text*、" +"*mark*、*tag*、*image* 或 *window* 中的任何一個傳入 true,可將傾印限制在所選" +"的種類。如果有給定 *command*,則會針對每個三元組呼叫一次,並以這三個值作為引" +"數,且不會回傳任何內容。" #: ../../library/tkinter.rst:5677 msgid "" @@ -7313,22 +8763,28 @@ msgid "" "peer covers the same lines as this widget; standard text options, including " "*startline* and *endline*, may be given to override this." msgstr "" +"建立一個路徑名稱為 *newPathName* 的對等文字元件,它會共用此元件底層的資料(文" +"字、標記、標籤、圖片和復原堆疊)。透過任何對等元件所做的變更都會反映在所有對" +"等元件上。預設情況下,對等元件會涵蓋與此元件相同的行;可以提供標準的文字選項" +"(包括 *startline* 和 *endline*)來覆寫此行為。" #: ../../library/tkinter.rst:5689 msgid "" "Return a tuple of the path names of this widget's peers, not including the " "widget itself." -msgstr "" +msgstr "回傳此元件所有對等元件的路徑名稱組成的 tuple,不包括該元件本身。" #: ../../library/tkinter.rst:5696 msgid "" "Adjust the view so that the location given by *what* is visible. This is an " "obsolete equivalent of :meth:`see`, which should be used instead." msgstr "" +"調整檢視區使得由 *what* 指定的位置可見。這是已過時的 :meth:`see` 等價方法,應" +"改用後者。" #: ../../library/tkinter.rst:5702 msgid "Variable classes" -msgstr "" +msgstr "變數類別" #: ../../library/tkinter.rst:5706 msgid "" @@ -7338,6 +8794,10 @@ msgid "" "so that changes propagate both ways: updating the variable updates every " "widget bound to it, and a user editing such a widget updates the variable." msgstr "" +"Tk 變數包裝器的基底類別。Tk 變數是儲存在 Tcl 直譯器中的一個值,可以透過元件" +"的 *variable* 或 *textvariable* 選項將其連結至元件(請參閱 :ref:`coupling-" +"widget-variables`),如此一來變更會雙向傳播:更新變數會更新所有綁定至該變數的" +"元件,而使用者編輯該元件也會更新變數。" #: ../../library/tkinter.rst:5713 msgid "" @@ -7348,6 +8808,10 @@ msgid "" "generated. If *name* matches an existing variable and *value* is omitted, " "the existing value is retained." msgstr "" +"*master* 是擁有該變數之 Tcl 直譯器所屬的元件;如果省略,則使用預設的根視窗。" +"*value* 是初始值;如果省略,則使用型別特定的預設值。*name* 是該變數在 Tcl 直" +"譯器中的名稱;如果省略,則會產生一個形式為 ``'PY_VARnum'`` 的唯一名稱。如果 " +"*name* 符合現有的變數,且省略 *value*,則會保留現有的值。" #: ../../library/tkinter.rst:5721 msgid "" @@ -7355,6 +8819,9 @@ msgid "" "`StringVar`, :class:`IntVar`, :class:`DoubleVar` or :class:`BooleanVar` -- " "rather than :class:`!Variable` directly." msgstr "" +"在大多數情況下,你應該使用下面型別化的子類別之一 -- :class:`StringVar`、:" +"class:`IntVar`、:class:`DoubleVar` 或 :class:`BooleanVar` -- 而非直接使用 :" +"class:`!Variable`。" #: ../../library/tkinter.rst:5727 msgid "" @@ -7364,12 +8831,18 @@ msgid "" "recreates the Tcl variable to keep the widget working, but it is never unset " "again, leaking one Tcl variable per dropped wrapper." msgstr "" +"當 :class:`!Variable` 被垃圾回收時,其 Tcl 變數會被取消設定。只要有元件連結至" +"該變數,就應保留對它的參照,例如將其儲存為屬性而非區域變數。否則 Tk 會重新建" +"立該 Tcl 變數以維持元件正常運作,但該變數將不會再被取消設定,導致每個被捨棄的" +"包裝器都會洩漏一個 Tcl 變數。" #: ../../library/tkinter.rst:5733 msgid "" "Two variables now compare equal (``==``) only when they have the same name, " "are of the same class, and belong to the same Tcl interpreter." msgstr "" +"現在只有當兩個變數的名稱相同、類別相同且屬於同一個 Tcl 直譯器時,比較" +"(``==``)才會相等。" #: ../../library/tkinter.rst:5739 msgid "" @@ -7377,15 +8850,17 @@ msgid "" "returned as a string; the typed subclasses convert it to the appropriate " "Python type." msgstr "" +"回傳變數目前的值。對於基底類別,該值會以字串形式回傳;型別化的子類別則會將其" +"轉換為適當的 Python 型別。" #: ../../library/tkinter.rst:5748 msgid "" "Set the variable to *value*. :meth:`initialize` is an alias of :meth:`!set`." -msgstr "" +msgstr "將變數設為 *value*。:meth:`initialize` 是 :meth:`!set` 的別名。" #: ../../library/tkinter.rst:5751 ../../library/tkinter.rst:5882 msgid "The *initialize* spelling." -msgstr "" +msgstr "*initialize* 拼寫方式。" #: ../../library/tkinter.rst:5756 msgid "" @@ -7393,6 +8868,9 @@ msgid "" "*mode*. *mode* is one of the strings ``'array'``, ``'read'``, ``'write'`` or " "``'unset'``, or a list or tuple of such strings." msgstr "" +"註冊 *callback*,使其在變數依照 *mode* 被存取時被呼叫。*mode* 為字串 " +"``'array'``、``'read'``、``'write'`` 或 ``'unset'`` 之一,或是這些字串所組成" +"的 list 或 tuple。" #: ../../library/tkinter.rst:5761 msgid "" @@ -7400,12 +8878,14 @@ msgid "" "Tcl variable, an index (or an empty string if the variable is not an element " "of an array), and the *mode* that triggered the call." msgstr "" +"觸發時,*callback* 會以三個引數被呼叫:Tcl 變數的名稱、索引(如果該變數不是陣" +"列的元素,則為空字串),以及觸發此次呼叫的 *mode*。" #: ../../library/tkinter.rst:5765 msgid "" "Return the internal name of the registered callback, which can be passed to :" "meth:`trace_remove`." -msgstr "" +msgstr "回傳已註冊回呼的內部名稱,該名稱可以傳入 :meth:`trace_remove`。" #: ../../library/tkinter.rst:5772 msgid "" @@ -7413,6 +8893,8 @@ msgid "" "was passed to :meth:`trace_add`, and *cbname* is the callback name returned " "by :meth:`trace_add`." msgstr "" +"從變數中移除一個追蹤回呼。*mode* 必須符合傳給 :meth:`trace_add` 的 *mode*," +"而 *cbname* 則是 :meth:`trace_add` 所回傳的回呼名稱。" #: ../../library/tkinter.rst:5780 msgid "" @@ -7420,6 +8902,8 @@ msgid "" "set on the variable, where *modes* is a tuple of mode strings and *cbname* " "is the internal callback name." msgstr "" +"回傳一個由 ``(modes, cbname)`` 配對組成的 list,用於描述目前設定在該變數上的" +"所有追蹤,其中 *modes* 是模式字串組成的 tuple,*cbname* 則是內部的回呼名稱。" #: ../../library/tkinter.rst:5791 msgid "" @@ -7428,66 +8912,75 @@ msgid "" "write or unset. Return the internal name of the registered callback. :meth:" "`trace` is an alias of :meth:`!trace_variable`." msgstr "" +"註冊 *callback*,使其在變數依照 *mode* 被存取時被呼叫。*mode* 為字串 " +"``'r'``、``'w'`` 或 ``'u'`` 之一,分別代表讀取、寫入或取消設定。回傳已註冊回" +"呼的內部名稱。:meth:`trace` 是 :meth:`!trace_variable` 的別名。" #: ../../library/tkinter.rst:5798 msgid "" "Use :meth:`trace_add` instead. This method wraps a Tcl feature that was " "removed in Tcl 9.0." msgstr "" +"請改用 :meth:`trace_add`。此方法包裝了一個已在 Tcl 9.0 中移除的 Tcl 功能。" #: ../../library/tkinter.rst:5804 msgid "" "Remove the trace callback named *cbname* registered for *mode* with :meth:" "`trace_variable`." msgstr "" +"移除以 :meth:`trace_variable` 為 *mode* 註冊、名為 *cbname* 的追蹤回呼。" #: ../../library/tkinter.rst:5807 msgid "" "Use :meth:`trace_remove` instead. This method wraps a Tcl feature that was " "removed in Tcl 9.0." msgstr "" +"請改用 :meth:`trace_remove`。此方法包裝了一個已在 Tcl 9.0 中移除的 Tcl 功能。" #: ../../library/tkinter.rst:5813 msgid "" "Return a list of ``(mode, cbname)`` pairs for all traces set on the variable " "with :meth:`trace_variable`." msgstr "" +"回傳一個由 ``(mode, cbname)`` 配對組成的 list,代表以 :meth:`trace_variable` " +"設定在該變數上的所有追蹤。" #: ../../library/tkinter.rst:5816 msgid "" "Use :meth:`trace_info` instead. This method wraps a Tcl feature that was " "removed in Tcl 9.0." msgstr "" +"請改用 :meth:`trace_info`。此方法包裝了一個已在 Tcl 9.0 中移除的 Tcl 功能。" #: ../../library/tkinter.rst:5823 msgid "" "A :class:`Variable` subclass that holds a string. The default value is " "``''``." -msgstr "" +msgstr "一個持有字串的 :class:`Variable` 子類別。預設值為 ``''``。" #: ../../library/tkinter.rst:5828 msgid "Return the value of the variable as a :class:`str`." -msgstr "" +msgstr "以 :class:`str` 回傳變數的值。" #: ../../library/tkinter.rst:5833 msgid "" "A :class:`Variable` subclass that holds an integer. The default value is " "``0``." -msgstr "" +msgstr "一個持有整數的 :class:`Variable` 子類別。預設值為 ``0``。" #: ../../library/tkinter.rst:5838 msgid "Return the value of the variable as an :class:`int`." -msgstr "" +msgstr "以 :class:`int` 回傳變數的值。" #: ../../library/tkinter.rst:5843 msgid "" "A :class:`Variable` subclass that holds a float. The default value is " "``0.0``." -msgstr "" +msgstr "一個持有浮點數的 :class:`Variable` 子類別。預設值為 ``0.0``。" #: ../../library/tkinter.rst:5848 msgid "Return the value of the variable as a :class:`float`." -msgstr "" +msgstr "以 :class:`float` 回傳變數的值。" #: ../../library/tkinter.rst:5854 msgid "" @@ -7498,24 +8991,33 @@ msgid "" "cannot read, raising :exc:`TclError`. Set ``LC_NUMERIC`` to a locale that " "uses a period (such as ``'C'``) to avoid this." msgstr "" +"浮點數值一律以句點(``.``)作為小數點分隔符號來剖析,但 :class:`Spinbox`、:" +"class:`Scale` 和 :class:`ttk.Spinbox ` 會依照 " +"``LC_NUMERIC`` 區域設定來格式化它。在使用逗號的區域設定下,它們會產生一個 :" +"meth:`get` 無法讀取的值,並引發 :exc:`TclError`。請將 ``LC_NUMERIC`` 設為使用" +"句點的區域設定(例如 ``'C'``)以避免此問題。" #: ../../library/tkinter.rst:5865 msgid "" "A :class:`Variable` subclass that holds a boolean. The default value is " "``False``." -msgstr "" +msgstr "一個持有布林值的 :class:`Variable` 子類別。預設值為 ``False``。" #: ../../library/tkinter.rst:5870 msgid "" "Return the value of the variable as a :class:`bool`. Raise a :exc:" "`ValueError` if the value cannot be interpreted as a boolean." msgstr "" +"以 :class:`bool` 回傳變數的值。如果該值無法被解讀為布林值,則引發 :exc:" +"`ValueError`。" #: ../../library/tkinter.rst:5879 msgid "" "Set the variable to *value*, converting it to a boolean. :meth:`initialize` " "is an alias of :meth:`!set`." msgstr "" +"將變數設為 *value*,並將其轉換為布林值。:meth:`initialize` 是 :meth:`!set` 的" +"別名。" #: ../../library/tkinter.rst:5887 msgid "Image classes" @@ -7529,6 +9031,10 @@ msgid "" "object deletes the underlying Tk image. Usually you create a :class:" "`PhotoImage` or :class:`BitmapImage` rather than an :class:`!Image` directly." msgstr "" +"Tk 圖片的基底類別。*imgtype* 是 Tk 圖片型別,為 ``'photo'`` 或 ``'bitmap'`` " +"之一。圖片是一個具名物件,可以透過元件的 *image* 選項顯示;刪除對 :class:`!" +"Image` 物件的所有參照,會刪除底層的 Tk 圖片。通常你會建立 :class:" +"`PhotoImage` 或 :class:`BitmapImage`,而不是直接建立 :class:`!Image`。" #: ../../library/tkinter.rst:5899 msgid "" @@ -7536,6 +9042,8 @@ msgid "" "queried and changed later with the mapping protocol (using ``image[key]``) " "or with the :meth:`configure` method." msgstr "" +"圖片的設定選項由 *cnf* 和 *kw* 給定,之後可以使用對映協定(透過 " +"``image[key]``)或 :meth:`configure` 方法來查詢和變更。" #: ../../library/tkinter.rst:5908 msgid "" @@ -7543,20 +9051,25 @@ msgid "" "depend on the image type; see :class:`PhotoImage` and :class:`BitmapImage`. :" "meth:`config` is an alias of :meth:`!configure`." msgstr "" +"修改圖片的一個或多個設定選項。有效的選項取決於圖片型別;請參閱 :class:" +"`PhotoImage` 和 :class:`BitmapImage`。:meth:`config` 是 :meth:`!configure` 的" +"別名。" #: ../../library/tkinter.rst:5915 msgid "Return the height of the image, in pixels." -msgstr "" +msgstr "以像素為單位,回傳圖片的高度。" #: ../../library/tkinter.rst:5919 msgid "Return the width of the image, in pixels." -msgstr "" +msgstr "以像素為單位,回傳圖片的寬度。" #: ../../library/tkinter.rst:5923 msgid "" "Return the type of the image, that is the value of *imgtype* with which it " "was created (for example ``'photo'`` or ``'bitmap'``)." msgstr "" +"回傳圖片的型別,即建立圖片時使用的 *imgtype* 值(例如 ``'photo'`` 或 " +"``'bitmap'``)。" #: ../../library/tkinter.rst:5929 msgid "" @@ -7565,6 +9078,9 @@ msgid "" "and (in Tk 8.6 and later) PNG files, read SVG files (in Tk 9.0 and later), " "and be drawn in widgets. Inherits from :class:`Image`." msgstr "" +"全彩圖片(Tk 的 ``photo`` 圖片型別),內部以每個像素不同程度的透明度儲存。它" +"可以讀寫 GIF、PPM/PGM 檔案,以及(在 Tk 8.6 及以後版本中)PNG 檔案,讀取 SVG " +"檔案(在 Tk 9.0 及以後版本中),並可繪製在元件中。繼承自 :class:`Image`。" #: ../../library/tkinter.rst:5935 msgid "" @@ -7573,6 +9089,9 @@ msgid "" "the file format handler), *width* and *height* (the size of the image, used " "when building it up piece by piece), *gamma* and *palette*." msgstr "" +"設定選項包括 *data* (以字串表示的圖片內容)、*file* (要讀取內容的檔案名" +"稱)、*format* (檔案格式處理常式的名稱)、*width* 和 *height* (圖片的大小," +"用於逐步建構圖片時使用)、*gamma* 和 *palette*。" #: ../../library/tkinter.rst:5942 msgid "" @@ -7580,14 +9099,16 @@ msgid "" "is displayed as transparent and the background of whatever window it is " "displayed in shows through." msgstr "" +"清空圖片;也就是說,將整個圖片設為沒有資料,使其顯示為透明,並讓其所顯示之視" +"窗的背景透出來。" #: ../../library/tkinter.rst:5948 msgid "Return the current value of the configuration option *option*." -msgstr "" +msgstr "回傳設定選項 *option* 目前的值。" #: ../../library/tkinter.rst:5952 msgid "Return a new :class:`PhotoImage` with a copy of this image." -msgstr "" +msgstr "回傳一個新的 :class:`PhotoImage`,其內容是此圖片的複本。" #: ../../library/tkinter.rst:5954 msgid "" @@ -7599,6 +9120,11 @@ msgid "" "and top edges of the rectangle but not the bottom or right edges. If " "*from_coords* is not given, the whole source image is copied." msgstr "" +"*from_coords* 指定要複製的來源圖片矩形子區域。它必須是一個由 1 到 4 個整數組" +"成的 tuple 或 list,即 ``(x1, y1, x2, y2)``。``(x1, y1)`` 和 ``(x2, y2)`` 指" +"定矩形的對角頂點。如果未指定 *x2* 和 *y2*,則預設為來源圖片的右下角。所複製的" +"像素包括矩形的左邊和上邊,但不包括下邊和右邊。如果未給定 *from_coords*,則會" +"複製整個來源圖片。" #: ../../library/tkinter.rst:5965 ../../library/tkinter.rst:5997 msgid "" @@ -7606,10 +9132,12 @@ msgid "" "meth:`zoom` or :meth:`subsample` methods. The value must be a single integer " "or a pair of integers." msgstr "" +"如果指定了 *zoom* 或 *subsample*,圖片會依照 :meth:`zoom` 或 :meth:" +"`subsample` 方法的方式進行轉換。此值必須是單一整數或一對整數。" #: ../../library/tkinter.rst:5969 msgid "Added the *from_coords*, *zoom* and *subsample* parameters." -msgstr "" +msgstr "新增了 *from_coords*、*zoom* 和 *subsample* 參數。" #: ../../library/tkinter.rst:5977 msgid "" @@ -7618,13 +9146,16 @@ msgid "" "are specified, the whole of *sourceImage* is copied into this image, " "starting at coordinates ``(0, 0)``." msgstr "" +"將 *sourceImage* (必須是 :class:`PhotoImage`)中的某個區域複製到此圖片中,可" +"能會進行像素縮放和/或次取樣。如果沒有指定任何選項,則會將整個 *sourceImage* " +"複製到此圖片,從座標 ``(0, 0)`` 開始。" #: ../../library/tkinter.rst:5982 ../../library/tkinter.rst:6094 #: ../../library/tkinter.rst:6150 msgid "" "*from_coords* specifies a rectangular sub-region of the source image to be " "copied, as in the :meth:`copy` method." -msgstr "" +msgstr "*from_coords* 指定要複製的來源圖片矩形子區域,如同 :meth:`copy` 方法。" #: ../../library/tkinter.rst:5985 msgid "" @@ -7635,6 +9166,11 @@ msgid "" "If *x2* and *y2* are specified, the source region is replicated if necessary " "to fill the destination region in a tiled fashion." msgstr "" +"*to* 指定目的圖片中要受影響的矩形子區域。它必須是一個由 1 到 4 個整數組成的 " +"tuple 或 list,即 ``(x1, y1, x2, y2)``。如果未指定 *x2* 和 *y2*,則預設為 " +"``(x1, y1)`` 加上來源區域的大小(如果有指定次取樣和縮放,則為次取樣和縮放後的" +"大小)。如果有指定 *x2* 和 *y2*,且有必要的話,來源區域會以並排方式複製,以填" +"滿目的區域。" #: ../../library/tkinter.rst:5993 msgid "" @@ -7642,6 +9178,8 @@ msgid "" "necessary, so that the region being copied into is at the bottom-right " "corner of the image." msgstr "" +"如果 *shrink* 為 true,則會在必要時縮小目的圖片的大小,使被複製的區域位於圖片" +"的右下角。" #: ../../library/tkinter.rst:6001 msgid "" @@ -7652,10 +9190,14 @@ msgid "" "destination. With ``'set'``, the old contents of the destination image are " "discarded and the source image is used as-is." msgstr "" +"*compositingrule* 指定來源圖片中的透明像素要如何與目的圖片結合。使用預設值 " +"``'overlay'`` 時,目的圖片原有的內容仍然可見,如同來源圖片被印在一張透明底片" +"上,並疊放在目的圖片之上。使用 ``'set'`` 時,目的圖片原有的內容會被捨棄,並直" +"接使用來源圖片。" #: ../../library/tkinter.rst:6015 msgid "Return the image data." -msgstr "" +msgstr "回傳圖片資料。" #: ../../library/tkinter.rst:6017 msgid "" @@ -7664,6 +9206,9 @@ msgid "" "strings containing space-separated (one element per pixel/column) colors in " "``#RRGGBB`` format." msgstr "" +"*format* 指定要使用的圖片檔案格式處理常式名稱。如果未給定,則資料會以 tuple " +"形式回傳(每列一個元素),每個元素為一個字串,內含以空格分隔的顏色(每個像素/" +"欄一個元素),格式為 ``#RRGGBB``。" #: ../../library/tkinter.rst:6022 msgid "" @@ -7675,6 +9220,11 @@ msgid "" "and excluding ``(x2, y2)``. If *from_coords* is not given, the whole image " "is returned." msgstr "" +"*from_coords* 指定要回傳的圖片矩形區域。它必須是一個由 1 到 4 個整數組成的 " +"tuple 或 list,即 ``(x1, y1, x2, y2)``。如果只指定 *x1* 和 *y1*,則區域會從 " +"``(x1, y1)`` 延伸到圖片的右下角。如果指定了全部四個座標,則它們會指定該區域的" +"對角頂點,包含 ``(x1, y1)`` 但不包含 ``(x2, y2)``。如果未給定 *from_coords*," +"則會回傳整張圖片。" #: ../../library/tkinter.rst:6030 ../../library/tkinter.rst:6133 msgid "" @@ -7682,12 +9232,16 @@ msgid "" "information; in all transparent pixels the color is replaced by the " "specified color." msgstr "" +"如果有指定 *background*,資料就不會包含任何透明度資訊;所有透明像素的顏色都會" +"被替換為指定的顏色。" #: ../../library/tkinter.rst:6034 ../../library/tkinter.rst:6137 msgid "" "If *grayscale* is true, the data does not contain color information; all " "pixel data is transformed into grayscale." msgstr "" +"如果 *grayscale* 為 true,資料就不會包含顏色資訊;所有像素資料都會被轉換為灰" +"階。" #: ../../library/tkinter.rst:6042 msgid "" @@ -7695,6 +9249,8 @@ msgid "" "tuple of three integers between 0 and 255, representing the red, green and " "blue components respectively." msgstr "" +"以介於 0 到 255 之間的三個整數組成的 ``(r, g, b)`` tuple,回傳座標 (*x*, " +"*y*) 處像素的顏色,分別代表紅、綠、藍分量。" #: ../../library/tkinter.rst:6048 msgid "" @@ -7702,6 +9258,8 @@ msgid "" "string or a nested sequence of horizontal rows of pixel colors (for example " "``\"{red green} {blue yellow}\"``)." msgstr "" +"將圖片的像素設為 *data* 中給定的顏色,*data* 必須是一個字串,或是由像素顏色列" +"組成的巢狀序列(例如 ``\"{red green} {blue yellow}\"``)。" #: ../../library/tkinter.rst:6052 msgid "" @@ -7710,14 +9268,17 @@ msgid "" "y1)`` or ``(x1, y1, x2, y2)`` giving the top-left corner, and optionally the " "bottom-right corner, of the region. The default position is ``(0, 0)``." msgstr "" +"*to* 指定資料要被複製到的圖片區域座標。它必須是一個由 2 或 4 個整數組成的 " +"tuple 或 list,即 ``(x1, y1)`` 或 ``(x1, y1, x2, y2)``,用於給定該區域的左上" +"角,並可選擇性地給定右下角。預設位置為 ``(0, 0)``。" #: ../../library/tkinter.rst:6062 msgid "Read image data from the file named *filename* into the image." -msgstr "" +msgstr "從名為 *filename* 的檔案中讀取圖片資料到此圖片。" #: ../../library/tkinter.rst:6064 msgid "*format* specifies the format of the image data in the file." -msgstr "" +msgstr "*format* 指定檔案中圖片資料的格式。" #: ../../library/tkinter.rst:6066 msgid "" @@ -7729,12 +9290,17 @@ msgid "" "opposite corners of the region. If *from_coords* is not given, the whole of " "the image in the file is read." msgstr "" +"*from_coords* 指定要複製到目的圖片的圖片檔案資料矩形子區域。它必須是一個由 1 " +"到 4 個整數組成的 tuple 或 list,即 ``(x1, y1, x2, y2)``。如果只指定 *x1* 和 " +"*y1*,則區域會從 ``(x1, y1)`` 延伸到檔案中圖片的右下角。如果指定了全部四個座" +"標,則它們會指定該區域的對角頂點。如果未給定 *from_coords*,則會讀取檔案中的" +"整張圖片。" #: ../../library/tkinter.rst:6076 msgid "" "*to* specifies the coordinates of the top-left corner of the region of the " "image into which the data are read. The default is ``(0, 0)``." -msgstr "" +msgstr "*to* 指定資料要被讀入之圖片區域左上角的座標。預設為 ``(0, 0)``。" #: ../../library/tkinter.rst:6080 msgid "" @@ -7742,6 +9308,8 @@ msgid "" "the region into which the file data are read is at the bottom-right corner " "of the image." msgstr "" +"如果 *shrink* 為 true,則會在必要時縮小圖片的大小,使檔案資料被讀入的區域位於" +"圖片的右下角。" #: ../../library/tkinter.rst:6089 msgid "" @@ -7749,32 +9317,39 @@ msgid "" "*x*-th pixel in the X direction and every *y*-th pixel in the Y direction. " "If *y* is not given, it defaults to the same value as *x*." msgstr "" +"回傳一個新的 :class:`PhotoImage`,其以此圖片為基礎,但僅使用 X 方向每隔 *x* " +"個像素及 Y 方向每隔 *y* 個像素的像素。如果未給定 *y*,則預設與 *x* 相同。" #: ../../library/tkinter.rst:6097 ../../library/tkinter.rst:6153 msgid "Added the *from_coords* parameter." -msgstr "" +msgstr "新增了 *from_coords* 參數。" #: ../../library/tkinter.rst:6103 msgid "" "Return ``True`` if the pixel at coordinates (*x*, *y*) is fully transparent, " "``False`` otherwise." msgstr "" +"如果座標 (*x*, *y*) 處的像素完全透明,則回傳 ``True``,否則回傳 ``False``。" #: ../../library/tkinter.rst:6111 msgid "" "Make the pixel at coordinates (*x*, *y*) fully transparent if *boolean* is " "true, fully opaque otherwise." msgstr "" +"如果 *boolean* 為 true,則使座標 (*x*, *y*) 處的像素完全透明,否則使其完全不" +"透明。" #: ../../library/tkinter.rst:6120 msgid "Write image data from the image to the file named *filename*." -msgstr "" +msgstr "將圖片資料從圖片寫入到名為 *filename* 的檔案。" #: ../../library/tkinter.rst:6122 msgid "" "*format* specifies the name of the image file format handler to use. If it " "is not given, the format is guessed from the file extension." msgstr "" +"*format* 指定要使用的圖片檔案格式處理常式名稱。如果未給定,則會從檔案副檔名猜" +"測格式。" #: ../../library/tkinter.rst:6125 msgid "" @@ -7785,10 +9360,14 @@ msgid "" "specify diagonally opposite corners of the region. If *from_coords* is not " "given, the whole image is written." msgstr "" +"*from_coords* 指定要寫入的圖片矩形區域。它必須是一個由 1 到 4 個整數組成的 " +"tuple 或 list,即 ``(x1, y1, x2, y2)``。如果只指定 *x1* 和 *y1*,則區域會從 " +"``(x1, y1)`` 延伸到圖片的右下角。如果指定了全部四個座標,則它們會指定該區域的" +"對角頂點。如果未給定 *from_coords*,則會寫入整張圖片。" #: ../../library/tkinter.rst:6140 msgid "Added the *background* and *grayscale* parameters." -msgstr "" +msgstr "新增了 *background* 和 *grayscale* 參數。" #: ../../library/tkinter.rst:6146 msgid "" @@ -7796,6 +9375,8 @@ msgid "" "*x* in the X direction and *y* in the Y direction. If *y* is not given, it " "defaults to the same value as *x*." msgstr "" +"回傳一個新的 :class:`PhotoImage`,其為此圖片在 X 方向放大 *x* 倍、Y 方向放大 " +"*y* 倍後的結果。如果未給定 *y*,則預設與 *x* 相同。" #: ../../library/tkinter.rst:6160 msgid "" @@ -7803,6 +9384,8 @@ msgid "" "Each pixel displays a foreground color, a background color, or nothing " "(producing a transparent effect). Inherits from :class:`Image`." msgstr "" +"雙色圖片(Tk 的 ``bitmap`` 圖片型別),由 X11 點陣圖建立而成。每個像素會顯示" +"前景色、背景色,或什麼都不顯示(產生透明效果)。繼承自 :class:`Image`。" #: ../../library/tkinter.rst:6165 msgid "" @@ -7815,16 +9398,22 @@ msgid "" "zero. If *background* is set to an empty string, the background pixels are " "transparent." msgstr "" +"設定選項為 *data* 或 *file* (來源點陣圖,以 X11 點陣圖格式的字串或該格式檔案" +"的名稱給定)、*maskdata* 或 *maskfile* (遮罩點陣圖,形式相同),以及 " +"*foreground* 和 *background* (這兩種顏色)。對於遮罩為零的像素,圖片不顯示任" +"何內容;對於其他像素,來源為一的地方顯示前景色,來源為零的地方顯示背景色。如" +"果 *background* 設為空字串,則背景像素為透明。" #: ../../library/tkinter.rst:6175 msgid "" ":class:`!BitmapImage` has no methods of its own beyond those inherited from :" "class:`Image`." msgstr "" +":class:`!BitmapImage` 除了繼承自 :class:`Image` 的方法之外,沒有自己的方法。" #: ../../library/tkinter.rst:6180 msgid "Other classes" -msgstr "" +msgstr "其他類別" #: ../../library/tkinter.rst:6184 msgid "" @@ -7834,76 +9423,80 @@ msgid "" "event type, some attributes may be set to the string ``'??'`` to indicate " "that they are not meaningful. See :ref:`bindings-and-events`." msgstr "" +"綁定在 :meth:`Misc.bind` 上之回呼所傳入事件屬性的容器。:class:`!Event` 實例具" +"有以下屬性,每個屬性對應底層 Tk 事件的一個欄位;依事件型別的不同,有些屬性可" +"能會被設為字串 ``'??'``,以表示該屬性沒有意義。請參閱 :ref:`bindings-and-" +"events`。" #: ../../library/tkinter.rst:6194 msgid "The serial number of the event." -msgstr "" +msgstr "事件的序號。" #: ../../library/tkinter.rst:6198 msgid "The mouse button that was pressed or released (for button events)." -msgstr "" +msgstr "按下或釋放的滑鼠按鍵(用於按鍵事件)。" #: ../../library/tkinter.rst:6202 msgid "Whether the window has the focus (for ``Enter`` and ``Leave`` events)." -msgstr "" +msgstr "視窗是否具有焦點(用於 ``Enter`` 和 ``Leave`` 事件)。" #: ../../library/tkinter.rst:6207 msgid "" "The new height and width of the window (for ``Configure`` and ``Expose`` " "events)." -msgstr "" +msgstr "視窗新的高度和寬度(用於 ``Configure`` 和 ``Expose`` 事件)。" #: ../../library/tkinter.rst:6212 msgid "The keycode of the key that was pressed or released." -msgstr "" +msgstr "按下或釋放之按鍵的鍵碼。" #: ../../library/tkinter.rst:6216 msgid "" "The state of the event, as a number (for most events) or a string (for " "``Visibility`` events)." -msgstr "" +msgstr "事件的狀態,對大多數事件而言是數字,對 ``Visibility`` 事件而言是字串。" #: ../../library/tkinter.rst:6221 msgid "The timestamp of the event, in milliseconds." -msgstr "" +msgstr "事件的時間戳記,以毫秒為單位。" #: ../../library/tkinter.rst:6226 msgid "The pointer position relative to the widget, in pixels." -msgstr "" +msgstr "指標相對於元件的位置,以像素為單位。" #: ../../library/tkinter.rst:6231 msgid "" "The pointer position relative to the top-left corner of the screen, in " "pixels." -msgstr "" +msgstr "指標相對於螢幕左上角的位置,以像素為單位。" #: ../../library/tkinter.rst:6236 msgid "The character typed, as a string (for key events)." -msgstr "" +msgstr "輸入的字元,以字串表示(用於按鍵事件)。" #: ../../library/tkinter.rst:6240 msgid "``True`` if the event was sent by another application." -msgstr "" +msgstr "如果事件是由另一個應用程式傳送的,則為 ``True``。" #: ../../library/tkinter.rst:6244 msgid "The symbolic name of the key that was pressed or released." -msgstr "" +msgstr "按下或釋放之按鍵的符號名稱。" #: ../../library/tkinter.rst:6248 msgid "The numeric value of :attr:`keysym`." -msgstr "" +msgstr ":attr:`keysym` 的數值。" #: ../../library/tkinter.rst:6252 msgid "The :class:`EventType` of the event." -msgstr "" +msgstr "事件的 :class:`EventType`。" #: ../../library/tkinter.rst:6256 msgid "The widget on which the event occurred." -msgstr "" +msgstr "事件發生所在的元件。" #: ../../library/tkinter.rst:6260 msgid "The amount the mouse wheel was rotated (for ``MouseWheel`` events)." -msgstr "" +msgstr "滑鼠滾輪滾動的量(用於 ``MouseWheel`` 事件)。" #: ../../library/tkinter.rst:6265 msgid "" @@ -7913,6 +9506,11 @@ msgid "" "``Leave``, ``FocusIn``, ``FocusOut``, ``Configure``, ``Map``, ``Unmap``, " "``Expose``, ``Destroy`` and ``MouseWheel``." msgstr "" +"一個列舉 Tk 事件型別的 :class:`enum.StrEnum`,用作 :attr:`Event.type` 的值。" +"其成員包括(但不限於)\\ ``KeyPress``、``KeyRelease``、``ButtonPress``、" +"``ButtonRelease``、``Motion``、``Enter``、``Leave``、``FocusIn``、" +"``FocusOut``、``Configure``、``Map``、``Unmap``、``Expose``、``Destroy`` 和 " +"``MouseWheel``。" #: ../../library/tkinter.rst:6278 msgid "" @@ -7922,10 +9520,13 @@ msgid "" "reporting. Instances are created automatically by :meth:`Misc.register`; " "this class is not normally used directly." msgstr "" +"包裝 Python 回呼的內部輔助工具,使其可以從 Tcl 呼叫。*func* 是 Python 函式," +"*subst* 是一個選擇性的函式,用於預先處理 Tcl 引數,*widget* 則是用於錯誤回報" +"的元件。實例是由 :meth:`Misc.register` 自動建立;此類別通常不會直接被使用。" #: ../../library/tkinter.rst:6288 msgid "Module-level functions" -msgstr "" +msgstr "模組層級函式" #: ../../library/tkinter.rst:6292 msgid "" @@ -7952,12 +9553,18 @@ msgid "" "explicit *master* --- raise a :exc:`RuntimeError`. Call this early in larger " "applications to make the root window explicit." msgstr "" +"抑制隱含預設根視窗的建立。此後 :mod:`!tkinter` 不會再自動建立共用的預設根視" +"窗,且依賴預設根視窗的操作 --- 例如在未提供明確 *master* 的情況下建構元件 " +"--- 會引發 :exc:`RuntimeError`。請在較大型的應用程式中盡早呼叫此函式,以明確" +"指定根視窗。" #: ../../library/tkinter.rst:6312 msgid "" "Run the Tk main event loop on the default root window until all windows are " "destroyed. Equivalent to calling :meth:`Misc.mainloop` on the default root." msgstr "" +"在預設根視窗上執行 Tk 主事件迴圈,直到所有視窗都被摧毀為止。等同於在預設根視" +"窗上呼叫 :meth:`Misc.mainloop`。" #: ../../library/tkinter.rst:6318 msgid "" @@ -7965,26 +9572,30 @@ msgid "" "``'on'`` and similar, or their false counterparts) to a Python :class:" "`bool`. Raise :exc:`TclError` for an invalid value." msgstr "" +"將 Tcl 布林字串 *s* (``'1'``、``'true'``、``'yes'``、``'on'`` 及類似字串之" +"一,或其相反的字串)轉換為 Python 的 :class:`bool`。如果值無效,則引發 :exc:" +"`TclError`。" #: ../../library/tkinter.rst:6325 msgid "" "Convert *s* to a floating-point number. This is the built-in :class:`float`." -msgstr "" +msgstr "將 *s* 轉換為浮點數。這就是內建的 :class:`float`。" #: ../../library/tkinter.rst:6330 msgid "Convert *s* to an integer. This is the built-in :class:`int`." -msgstr "" +msgstr "將 *s* 轉換為整數。這就是內建的 :class:`int`。" #: ../../library/tkinter.rst:6335 msgid "" "Return the names of all existing images in the default root's interpreter." -msgstr "" +msgstr "回傳預設根視窗之直譯器中所有現存圖片的名稱。" #: ../../library/tkinter.rst:6339 msgid "" "Return the available image types (such as ``'photo'`` and ``'bitmap'``) in " "the default root's interpreter." msgstr "" +"回傳預設根視窗之直譯器中可用的圖片型別(例如 ``'photo'`` 和 ``'bitmap'``)。" #: ../../library/tkinter.rst:6346 msgid "File handlers" @@ -8063,21 +9674,23 @@ msgstr "用於 *mask* 引數的常數。" #: ../../library/tkinter.rst:6394 msgid "Constants" -msgstr "" +msgstr "常數" #: ../../library/tkinter.rst:6396 msgid "" "The following symbolic constants are available in both the :mod:`!tkinter` " "and :mod:`!tkinter.constants` namespaces." msgstr "" +"以下符號常數在 :mod:`!tkinter` 和 :mod:`!tkinter.constants` 命名空間中皆可使" +"用。" #: ../../library/tkinter.rst:6403 msgid "Truthy values, all equal to the integer ``1``." -msgstr "" +msgstr "真值,其值皆等於整數 ``1``。" #: ../../library/tkinter.rst:6409 msgid "Falsy values, all equal to the integer ``0``." -msgstr "" +msgstr "假值,其值皆等於整數 ``0``。" #: ../../library/tkinter.rst:6424 msgid "" @@ -8085,11 +9698,14 @@ msgid "" "edges) plus ``CENTER`` (``'center'``), used as values for the *anchor* and " "*sticky* options and by methods such as :meth:`Misc.grid_anchor`." msgstr "" +"羅盤方向(``'n'``、``'s'``、``'e'``、``'w'`` 及其對角線和邊)加上 " +"``CENTER``\\ (``'center'``),用作 *anchor* 和 *sticky* 選項的值,以及 :" +"meth:`Misc.grid_anchor` 等方法所使用。" #: ../../library/tkinter.rst:6433 msgid "" "Sides for the *side* option of the packer (see :meth:`Pack.pack_configure`)." -msgstr "" +msgstr "packer 之 *side* 選項的邊(請參閱 :meth:`Pack.pack_configure`)。" #: ../../library/tkinter.rst:6440 msgid "" @@ -8099,29 +9715,32 @@ msgstr "packer 的 *fill* 選項值:``'x'``、``'y'``、``'both'`` 或 ``'none #: ../../library/tkinter.rst:6450 msgid "Values for the *relief* option, which controls a widget's 3-D border." -msgstr "" +msgstr "*relief* 選項的值,用於控制元件的立體邊框。" #: ../../library/tkinter.rst:6455 msgid "" "Values for the *orient* option of widgets such as :class:`Scale`, :class:" "`Scrollbar` and :class:`PanedWindow`." msgstr "" +"用於 :class:`Scale`、:class:`Scrollbar` 和 :class:`PanedWindow` 等元件之 " +"*orient* 選項的值。" #: ../../library/tkinter.rst:6461 msgid "" "Values for the *wrap* option of the :class:`Text` widget, selecting line " "wrapping on character or word boundaries." -msgstr "" +msgstr ":class:`Text` 元件之 *wrap* 選項的值,用於選擇依字元或單字邊界換行。" #: ../../library/tkinter.rst:6466 msgid "The text-alignment value ``'baseline'``." -msgstr "" +msgstr "文字對齊值 ``'baseline'``。" #: ../../library/tkinter.rst:6471 msgid "" "Values for the *bordermode* option of the placer (see :meth:`Place." "place_configure`)." msgstr "" +"placer 之 *bordermode* 選項的值(請參閱 :meth:`Place.place_configure`)。" #: ../../library/tkinter.rst:6482 msgid "" @@ -8130,30 +9749,37 @@ msgid "" "``'current'``, ``'end'``, ``'anchor'`` and the bounds of the selection " "(``'sel.first'`` and ``'sel.last'``)." msgstr "" +":class:`Text`、:class:`Entry`、:class:`Listbox` 和 :class:`Canvas` 元件使用的" +"符號索引,例如 ``'insert'``\\ (插入游標)、``'current'``、``'end'``、" +"``'anchor'`` 以及選取範圍的邊界(``'sel.first'`` 和 ``'sel.last'``)。" #: ../../library/tkinter.rst:6489 msgid "" "The special tag ``'all'``, which matches every item of a :class:`Canvas` or " "every character of a :class:`Text` (for example ``canvas.delete(ALL)``)." msgstr "" +"特殊標籤 ``'all'``,用於符合 :class:`Canvas` 的所有項目或 :class:`Text` 的所" +"有字元(例如 ``canvas.delete(ALL)``)。" #: ../../library/tkinter.rst:6497 msgid "Values for the *state* option of various widgets and items." -msgstr "" +msgstr "各種元件與項目之 *state* 選項的值。" #: ../../library/tkinter.rst:6505 msgid "" "Menu entry types, used as the *itemType* argument of :meth:`Menu.add` and :" "meth:`Menu.insert`." msgstr "" +"選單項目型別,用作 :meth:`Menu.add` 和 :meth:`Menu.insert` 的 *itemType* 引" +"數。" #: ../../library/tkinter.rst:6513 msgid "Values for the *selectmode* option of the :class:`Listbox` widget." -msgstr "" +msgstr ":class:`Listbox` 元件之 *selectmode* 選項的值。" #: ../../library/tkinter.rst:6519 msgid "Values for the *style* option of :class:`Canvas` arc items." -msgstr "" +msgstr ":class:`Canvas` 弧形項目之 *style* 選項的值。" #: ../../library/tkinter.rst:6527 msgid "" @@ -8161,33 +9787,38 @@ msgid "" "*joinstyle* (``'round'``, ``'bevel'``, ``'miter'``) options of :class:" "`Canvas` line items." msgstr "" +":class:`Canvas` 線條項目之 *capstyle* (``'butt'``、``'projecting'``、" +"``'round'``)和 *joinstyle* (``'round'``、``'bevel'``、``'miter'``)選項的" +"值。" #: ../../library/tkinter.rst:6534 msgid "" "Values for the *arrow* option of :class:`Canvas` line items, indicating " "which ends have arrowheads." -msgstr "" +msgstr ":class:`Canvas` 線條項目之 *arrow* 選項的值,用於指示哪一端有箭頭。" #: ../../library/tkinter.rst:6540 msgid "" "The first argument passed by a :class:`Scrollbar` to the :meth:`XView.xview` " "or :meth:`YView.yview` method of the scrolled widget." msgstr "" +"由 :class:`Scrollbar` 傳給被捲動元件之 :meth:`XView.xview` 或 :meth:`YView." +"yview` 方法的第一個引數。" #: ../../library/tkinter.rst:6546 msgid "" "Values for the *what* argument of :meth:`XView.xview_scroll` and :meth:" "`YView.yview_scroll`." msgstr "" +":meth:`XView.xview_scroll` 和 :meth:`YView.yview_scroll` 的 *what* 引數的值。" #: ../../library/tkinter.rst:6553 msgid "Other option values: ``'underline'``, ``'numeric'`` and ``'dotbox'``." -msgstr "" +msgstr "其他選項值:``'underline'``、``'numeric'`` 和 ``'dotbox'``。" #: ../../library/tkinter.rst:591 -#, fuzzy msgid "geometry management (widgets)" -msgstr "佈局管理(geometry management)" +msgstr "佈局管理(元件)" #: ../../library/tkinter.rst:591 msgid "packing (widgets)" diff --git a/library/tkinter.scrolledtext.po b/library/tkinter.scrolledtext.po index 8ab35ffed3..c2b2f30faa 100644 --- a/library/tkinter.scrolledtext.po +++ b/library/tkinter.scrolledtext.po @@ -41,6 +41,10 @@ msgid "" "class:`~tkinter.Frame` object. This allows the :class:`ScrolledText` widget " "to be used directly to achieve most normal geometry management behavior." msgstr "" +"文字小工具與捲軸被一起打包在 :class:`~tkinter.Frame` 中,其 :class:`~tkinter." +"Pack`、:class:`~tkinter.Grid` 和 :class:`~tkinter.Place` 幾何管理器的方法則是" +"從該 :class:`~tkinter.Frame` 物件取得。這讓 :class:`ScrolledText` 小工具能直" +"接用來達成大多數一般的幾何管理行為。" #: ../../library/tkinter.scrolledtext.rst:25 msgid "" diff --git a/library/tkinter.ttk.po b/library/tkinter.ttk.po index 25161391c9..0fb533f0a2 100644 --- a/library/tkinter.ttk.po +++ b/library/tkinter.ttk.po @@ -32,6 +32,9 @@ msgid "" "native theme, giving an application a better and more consistent look and " "feel than the classic :mod:`tkinter` widgets, whose appearance is fixed." msgstr "" +":mod:`!tkinter.ttk` 模組提供了對 Tk 主題化元件集(於 Tk 8.5 中引入)的存取。" +"其元件會依照平台的原生主題調整外觀,因此比起外觀固定的傳統 :mod:`tkinter` 元" +"件,能讓應用程式呈現更好、更一致的外觀與體驗。" #: ../../library/tkinter.ttk.rst:21 msgid "" @@ -47,17 +50,21 @@ msgid "" "coupling and event binding. Those foundational concepts are covered in the :" "mod:`tkinter` documentation and are not repeated here." msgstr "" +"Ttk 元件的用法與傳統 :mod:`tkinter` 元件相同,並共用相同的基礎機制:元件階" +"層、佈局管理器、變數耦合與事件繫結。這些基礎概念已在 :mod:`tkinter` 文件中說" +"明,此處不再重複。" #: ../../library/tkinter.ttk.rst:36 msgid "" "`Tk Widget Styling Support (TIP #48) `_" msgstr "" +"`Tk Widget Styling Support (TIP #48) `_" #: ../../library/tkinter.ttk.rst:37 msgid "" "The Tcl Improvement Proposal that introduced the themed widget styling " "engine." -msgstr "" +msgstr "引入主題化元件樣式引擎的 Tcl 改進提案。" #: ../../library/tkinter.ttk.rst:41 msgid "Using Ttk" @@ -92,6 +99,11 @@ msgid "" "`PanedWindow`, :class:`Radiobutton`, :class:`Scale`, :class:`Scrollbar` and :" "class:`Spinbox`) to automatically replace the Tk widgets." msgstr "" +"這段程式碼會讓多個 :mod:`!tkinter.ttk` 元件(:class:`Button`、:class:" +"`Checkbutton`、:class:`Entry`、:class:`Frame`、:class:`Label`、:class:" +"`LabelFrame`、:class:`Menubutton`、:class:`OptionMenu`、:class:" +"`PanedWindow`、:class:`Radiobutton`、:class:`Scale`、:class:`Scrollbar` 和 :" +"class:`Spinbox`)自動取代 Tk 元件。" #: ../../library/tkinter.ttk.rst:61 msgid "" @@ -100,6 +112,9 @@ msgid "" "imports the module as ``from tkinter import ttk`` and refers to the themed " "widgets explicitly, such as ``ttk.Button``." msgstr "" +"使用 ``from tkinter.ttk import *`` 來覆寫傳統元件,對調整既有程式碼而言很方" +"便,但撰寫新程式碼時,通常以 ``from tkinter import ttk`` 匯入模組,並明確地" +"以 ``ttk.Button`` 這類方式參照主題化元件,會讓程式碼更清楚。" #: ../../library/tkinter.ttk.rst:67 msgid "" @@ -110,6 +125,10 @@ msgid "" "Ttk widgets. Instead, use the :class:`ttk.Style